Closed
Conversation
* fix: make direct call to cdn purge --------- Co-authored-by: Ahtesham Quraish <ahtesham.quraish@192.168.10.4>
* switch to new format for resource id * fixing tests * prefer dictionary resource id - fall back to learning_resource_id
OpenAPI ChangesShow/hide 412 changes: 30 error, 21 warning, 361 info |
Comment on lines
+1027
to
+1030
| resource_category = serializers.ReadOnlyField( | ||
| default=constants.LearningResourceType.learning_path.value | ||
| ) | ||
|
|
There was a problem hiding this comment.
Bug: Creating a LearningPath via the API fails because the required resource_category field is not set, as it is incorrectly configured as a ReadOnlyField in the serializer.
Severity: CRITICAL
Suggested Fix
Explicitly set the resource_category in the LearningPathResourceSerializer.create() method, similar to how resource_type is set. Add validated_data["resource_category"] = constants.LearningResourceType.learning_path.value to the method.
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: learning_resources/serializers.py#L1027-L1030
Potential issue: When creating a `LearningPath` via the API, the `resource_category`
field is not populated, which will cause a database `IntegrityError`. The
`LearningPathResourceSerializer` defines `resource_category` as a
`serializers.ReadOnlyField`, which is ignored during input processing, and its `default`
value is not used. The serializer's `create` method also fails to set this field. Since
the `resource_category` model field is non-nullable, any API request to create a
`LearningPath` will fail upon saving to the database.
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.
Shankar Ambady
Ahtesham Quraish
Anastasia Beglova