Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graceful Error Handling for Missing Models in EVENT_SINK_CLICKHOUSE_MODEL_CONFIG to Prevent Platform Disruptions #96

Closed
anfbermudezme opened this issue Sep 30, 2024 · 1 comment · Fixed by #97

Comments

@anfbermudezme
Copy link

anfbermudezme commented Sep 30, 2024

Issue Type: Enhancement

Summary

Improve error handling when retrieving models within the get_model method and signals to prevent disruptions in platform processes such as course enrollments when the model is not present in the EVENT_SINK_CLICKHOUSE_MODEL_CONFIG setting.

Description

Currently, when making a request using the get_model method and the specified model does not exist, an exception is raised, logging the error here: Link to Code.

However, within the signal handling process, the method *Model*.objects.get is used to retrieve models. If the model is missing from the EVENT_SINK_CLICKHOUSE_MODEL_CONFIG setting, it throws a AttributeError: 'NoneType' object has no attribute 'objects'” exception, as the process does not terminate gracefully. This forces the model to be explicitly included in the configuration, leading to interruptions in critical platform processes like course enrollments (Link to Signals).

Suggested Enhancement

The current behavior mandates that models must exist in the configuration. Failure to do so results in unhandled exceptions that break the natural flow of platform operations. To enhance robustness:

  1. Graceful Fallback: Implement a more graceful fallback mechanism in the case where the model is not found. Instead of raising a hard exception, log the error and allow the process to continue where possible.
  2. Soft Error Handling: Adjust the plugin's behavior to report such errors without crashing core functionalities of the platform, allowing the default platform behavior to continue unaffected.

This improvement will ensure that platform processes like enrollments do not get disrupted, even if the plugin configuration is incomplete.

Steps to Reproduce

  1. Remove CourseEnrollment from the EVENT_SINK_CLICKHOUSE_MODEL_CONFIG setting.
  2. Attempt to enroll a user through any part of the platform.
  3. Observe the thrown exception and the resulting error message.

Expected Behavior

  • If the model is not found, log the error and continue the process without causing a crash.
  • Enrollment or other platform processes should continue unaffected by missing model configurations within the plugin.

Actual Behavior

  • An exception is raised (AttributeError: 'NoneType' object has no attribute 'objects'”) when 2024-08-26 21:56:16,853 ERROR 1 [platform_plugin_aspects.utils] [user None] [ip None] utils.py:218 - Unable to find model config for course_enrollment, which stops the process and prevents course enrollments from completing.

Proposed Fix

  • Update the error handling logic in both the get_model method and signal processing to ensure proper error reporting without breaking core platform functionalities.

Environment

  • Platform version: Redwood
  • Plugin version: v0.11.1
@Ian2012
Copy link
Contributor

Ian2012 commented Oct 4, 2024

hi @anfbermudezme thanks for the report.

@bmtcril I think we can disable sinks if the model is not found:

return enabled or waffle_flag.is_enabled()

To:

        return  self.get_model() and (enabled or waffle_flag.is_enabled())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging a pull request may close this issue.

2 participants