Repository navigation
Fix duplicated Content-Type header and reject mismatched PATCH ids - #62
Open
jgoclawski wants to merge 2 commits into
Open
jgoclawski wants to merge 2 commits into
jgoclawski wants to merge 2 commits into
Conversation
Before that there were 2 headers set, one default one "text/html". Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
Views that pass the loaded body straight to repository.update(data) used the body's id, so the update could hit a different object than the one the permission check loaded from the URL. marshmallow-jsonapi lets an "id" attribute overwrite data.id, so the id is checked both in the raw body and in the loaded payload. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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.
Summary
Two independent fixes, released ahead of the layered API redesign.
Content-Typeheader. JSON:API responses carried twoContent-Typeheaders: Flask's defaulttext/htmlandapplication/vnd.api+json. They now carry only the JSON:API one.BaseJsonApiResponse.base_headeris replaced bycontent_type.iddoes not match the endpoint.ResourceDetail.patchnow returns409when the body'sdata.id, or anidthat ends up in the loaded payload (for example throughattributes.id), differs from the URL id. Without this, a view that passes the loaded body straight torepository.update(data)updates the object named in the body after any permission check ran on the object named in the URL. A body without anidkeeps working as before.Behaviour changes
409instead of having the URL id silently win.Content-Typeheader passed to a JSON:API response is now overridden by the JSON:API one.Testing
data.id, mismatchedattributes.idwith and without a matchingdata.id, a numeric body id matching a string URL id, a body withoutid, and a body withoutdata.🤖 Generated with Claude Code