Ensured that patching a To-Many relationship correctly raises request error#1251
Merged
n2ygk merged 1 commit intodjango-json-api:mainfrom Sep 10, 2024
Merged
Conversation
Member
Author
|
To see failing drf master tests, go to https://github.com/django-json-api/django-rest-framework-json-api/actions/runs/10648325051/job/29517253464 open Run tox targets and scroll down to drfmaster tests. These tests have been failing for a while and as we ignore failing drfmaster tests, it is hard to notice it. Possibly have to think about it not to ignore it (as it hardly ever happens that it fails). And if one PR suddenly fails because of DRF changes, we can always force merge it. Anyway, there might be also other approaches, but that would be part of another PR/discussion. |
n2ygk
approved these changes
Sep 10, 2024
5 tasks
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.
Description of the Change
As of DRF upstream change encode/django-rest-framework#9455 our current tests with DRF master are failing. The reason being is that previous to the above change, parser attribute errors would get swallowed.
After this upstream change it occurred that we actually have an error in our code that an attribute error gets hidden and instead of raising a 500-error the code would just continue.
This happened when patching a To-Many relationship with
RelationshipViewwithNone. However, the JSON:API spec defines that for emptying a To-Many relationship, caller needs to pass empty array instead of None.So this PR ensures that when passing on
Nonewhen patching To-Many relationship, a proper request error (400) is returned instead of 500.Checklist
CHANGELOG.mdupdated (only for user relevant changes)AUTHORS