Closed
Conversation
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
OpenAPI ChangesShow/hide ## Changes for v0.yaml:Unexpected changes? Ensure your branch is up-to-date with |
| null=False, validators=[MinValueValidator(0.0), MaxValueValidator(2.0)] | ||
| ) | ||
| letter_grade = models.CharField(max_length=6, blank=True, null=True) # noqa: DJ001 | ||
| letter_grade = models.CharField(max_length=10, blank=True, null=True) # noqa: DJ001 |
There was a problem hiding this comment.
Bug: The override_user_grade function uses a validation is_letter_grade_valid that only allows single-character grades, contradicting the PR's intent to support multi-character grades.
Severity: MEDIUM
Suggested Fix
Update the validation logic in the is_letter_grade_valid function in courses/utils.py to align with the new max_length=10 for letter_grade. The regex should be modified to accept multi-character strings. Additionally, enhance the tests for override_user_grade to include cases with multi-character grades to prevent future regressions.
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: courses/models.py#L1907
Potential issue: The pull request updates the `letter_grade` field to support up to 10
characters, but the validation function `is_letter_grade_valid` was not updated
accordingly. This function, which is called by `override_user_grade`, still enforces a
single-character grade (`[A-F]`). Consequently, any attempt by an administrator to
manually set a multi-character grade (e.g., "Pass") via the API or the
`manage_certificates.py` management command will fail with a `ValidationError`. This
creates an inconsistency where multi-character grades can be synced from external
systems but cannot be manually set or overridden.
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.
annagav
renovate[bot]