Repository navigation
Conversation
A value the schema will not take comes from the request, so it is a bad request. The field managers raised a bare TypeError or ValueError for these, which plone.jsonapi.core renders as a 500: the caller is told the server broke when in fact the payload did. It also cost the error its identity. A caller writing many objects in one run could catch an APIError and carry on, naming the object that failed, but a TypeError carried nothing to distinguish a refused value from a genuine fault inside the server, so it had to be let through and ended the whole run with the field name and nothing else. Four raise sites, all of them reporting a value that arrived in the payload: a wrong type, a field that failed its own validator, and two copies of "multiple values for a single valued field". The messages are unchanged.
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 issue/feature this PR addresses
A value the schema will not take comes from the request, so it is a bad request. The field managers raise a bare
TypeErrororValueErrorfor these, which plone.jsonapi.core renders as a 500: the caller is told the server broke when in fact the payload did.It also costs the error its identity. A caller writing many objects in one run can catch an
APIErrorand carry on, naming the object that failed, but aTypeErrorcarries nothing to distinguish a refused value from a genuine fault inside the server, so it has to be let through and ends the whole run with the field name and nothing else.Current behavior before PR
Desired behavior after PR is merged
Four raise sites, all of them reporting a value that arrived in the payload: a wrong type, a field that failed its own validator, and two copies of "multiple values for a single valued field". The messages are unchanged, only the exception type is, from
TypeError/ValueErrortoBadRequestError.Verification
POSTa wrong-typed value (an int into aschema.Float) and a value that fails a field validator; both answer 400 with the same message as before.