Conversation
OpenAPI ChangesShow/hide ## Changes for v0.yaml:Unexpected changes? Ensure your branch is up-to-date with |
Comment on lines
1391
to
+1395
| EdxApiChangeEmailSettingsException: Raised if an unknown error was encountered during the edX API request | ||
| """ | ||
| edx_client = get_edx_api_client(user) | ||
| if edx_client is None: | ||
| return None |
There was a problem hiding this comment.
Bug: When edX API calls fail and return None, the caller inverts the user's email subscription status in the database instead of propagating the error.
Severity: HIGH
Suggested Fix
The calling view should explicitly check if the response from the subscription/unsubscription functions is None. If it is, the view should not update the database and should return an appropriate error response to indicate that the operation failed, rather than silently saving an incorrect state.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: openedx/api.py#L1391-L1395
Potential issue: When the `IGNORE_EDX_FAILURES` flag is true and an edX API client
cannot be obtained for a user, the functions `subscribe_to_edx_course_emails` and
`unsubscribe_from_edx_course_emails` return `None`. The caller in
`courses/views/v1/__init__.py` misinterprets this `None` value. For a subscription
request, it incorrectly sets `edx_emails_subscription` to `False`, and for an
unsubscription request, it sets it to `True`. This inverted state is saved to the
database, and the API returns a `200 OK` success response, masking the underlying
failure from the user.
Did we get this right? 👍 / 👎 to inform future reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Muhammad Anas
Muhammad Arslan
renovate[bot]
Rachel Lougee