Parse the request body once per request in the validators - #3568
Open
adamtheturtle wants to merge 1 commit into
Open
Parse the request body once per request in the validators#3568adamtheturtle wants to merge 1 commit into
adamtheturtle wants to merge 1 commit into
Conversation
The services validators each parsed the JSON body again, and the image validators each base64 decoded the image again. The parsed JSON and the decoded image now live on the validator context, computed on first use and shared by the rest of the chain. The Query API validators each parsed the whole multipart body again, and the response builder parsed it once more. The body is now parsed once in run_query_validators, after the Content-Type header has been validated, and the parsed form and the matched database are returned to the caller so that the response builder reuses them. Closes #3371 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
adamtheturtle
temporarily deployed
to
vuforia
September 7, 2026 22:20 — with
GitHub Actions
Inactive
adamtheturtle
temporarily deployed
to
vuforia
September 7, 2026 22:20 — with
GitHub Actions
Inactive
adamtheturtle
temporarily deployed
to
vuforia
September 7, 2026 22:20 — with
GitHub Actions
Inactive
adamtheturtle
temporarily deployed
to
vuforia
September 7, 2026 22:20 — with
GitHub Actions
Inactive
adamtheturtle
temporarily deployed
to
vuforia
September 7, 2026 22:20 — with
GitHub Actions
Inactive
adamtheturtle
temporarily deployed
to
vuforia
September 7, 2026 22:20 — with
GitHub Actions
Inactive
adamtheturtle
temporarily deployed
to
vuforia
September 7, 2026 22:20 — with
GitHub Actions
Inactive
adamtheturtle
temporarily deployed
to
vuforia
September 7, 2026 22:20 — with
GitHub Actions
Inactive
adamtheturtle
temporarily deployed
to
vuforia
September 7, 2026 22:20 — with
GitHub Actions
Inactive
adamtheturtle
temporarily deployed
to
vuforia
September 7, 2026 22:20 — with
GitHub Actions
Inactive
adamtheturtle
temporarily deployed
to
vuforia
September 7, 2026 22:20 — with
GitHub Actions
Inactive
adamtheturtle
temporarily deployed
to
vuforia
September 7, 2026 22:20 — with
GitHub Actions
Inactive
adamtheturtle
temporarily deployed
to
vuforia
September 7, 2026 22:20 — with
GitHub Actions
Inactive
adamtheturtle
temporarily deployed
to
vuforia
September 7, 2026 22:20 — with
GitHub Actions
Inactive
adamtheturtle
temporarily deployed
to
vuforia
September 7, 2026 22:20 — with
GitHub Actions
Inactive
adamtheturtle
temporarily deployed
to
vuforia
September 7, 2026 22:20 — with
GitHub Actions
Inactive
adamtheturtle
temporarily deployed
to
vuforia
September 7, 2026 22:20 — with
GitHub Actions
Inactive
adamtheturtle
temporarily deployed
to
vuforia
September 7, 2026 22:20 — with
GitHub Actions
Inactive
adamtheturtle
temporarily deployed
to
vuforia
September 7, 2026 22:20 — with
GitHub Actions
Inactive
adamtheturtle
temporarily deployed
to
vuforia
September 7, 2026 22:20 — with
GitHub Actions
Inactive
adamtheturtle
temporarily deployed
to
vuforia
September 7, 2026 22:20 — with
GitHub Actions
Inactive
adamtheturtle
temporarily deployed
to
vuforia
September 7, 2026 22:20 — with
GitHub Actions
Inactive
adamtheturtle
temporarily deployed
to
vuforia
September 7, 2026 22:20 — with
GitHub Actions
Inactive
adamtheturtle
temporarily deployed
to
vuforia
September 7, 2026 22:20 — with
GitHub Actions
Inactive
adamtheturtle
temporarily deployed
to
vuforia
September 7, 2026 22:20 — with
GitHub Actions
Inactive
adamtheturtle
temporarily deployed
to
vuforia
September 7, 2026 22:20 — with
GitHub Actions
Inactive
adamtheturtle
temporarily deployed
to
vuforia
September 7, 2026 22:20 — with
GitHub Actions
Inactive
adamtheturtle
temporarily deployed
to
vuforia
September 7, 2026 22:20 — with
GitHub Actions
Inactive
adamtheturtle
temporarily deployed
to
vuforia
September 7, 2026 22:20 — with
GitHub Actions
Inactive
adamtheturtle
temporarily deployed
to
vuforia
September 7, 2026 22:20 — with
GitHub Actions
Inactive
adamtheturtle
temporarily deployed
to
vuforia
September 7, 2026 22:20 — with
GitHub Actions
Inactive
adamtheturtle
temporarily deployed
to
vuforia
September 7, 2026 22:20 — with
GitHub Actions
Inactive
adamtheturtle
temporarily deployed
to
vuforia
September 7, 2026 22:20 — with
GitHub Actions
Inactive
adamtheturtle
temporarily deployed
to
vuforia
September 7, 2026 22:20 — with
GitHub Actions
Inactive
adamtheturtle
temporarily deployed
to
vuforia
September 7, 2026 22:20 — with
GitHub Actions
Inactive
adamtheturtle
temporarily deployed
to
vuforia
September 7, 2026 22:20 — with
GitHub Actions
Inactive
adamtheturtle
temporarily deployed
to
vuforia
September 7, 2026 22:20 — with
GitHub Actions
Inactive
adamtheturtle
had a problem deploying
to
vuforia
September 7, 2026 22:20 — with
GitHub Actions
Failure
adamtheturtle
temporarily deployed
to
vuforia
September 7, 2026 22:20 — with
GitHub Actions
Inactive
adamtheturtle
temporarily deployed
to
vuforia
September 7, 2026 22:20 — with
GitHub Actions
Inactive
adamtheturtle
temporarily deployed
to
vuforia
September 7, 2026 22:20 — with
GitHub Actions
Inactive
adamtheturtle
temporarily deployed
to
vuforia
September 7, 2026 22:20 — with
GitHub Actions
Inactive
adamtheturtle
temporarily deployed
to
vuforia
September 7, 2026 22:20 — with
GitHub Actions
Inactive
adamtheturtle
temporarily deployed
to
vuforia
September 7, 2026 22:20 — with
GitHub Actions
Inactive
adamtheturtle
temporarily deployed
to
vuforia
September 7, 2026 22:20 — with
GitHub Actions
Inactive
adamtheturtle
temporarily deployed
to
vuforia
September 7, 2026 22:20 — with
GitHub Actions
Inactive
adamtheturtle
temporarily deployed
to
vuforia
September 7, 2026 22:20 — with
GitHub Actions
Inactive
adamtheturtle
temporarily deployed
to
vuforia
September 7, 2026 22:20 — with
GitHub Actions
Inactive
adamtheturtle
temporarily deployed
to
vuforia
September 7, 2026 22:20 — with
GitHub Actions
Inactive
adamtheturtle
temporarily deployed
to
vuforia
September 7, 2026 22:20 — with
GitHub Actions
Inactive
adamtheturtle
temporarily deployed
to
vuforia
September 7, 2026 22:20 — with
GitHub Actions
Inactive
adamtheturtle
temporarily deployed
to
vuforia
September 7, 2026 22:20 — with
GitHub Actions
Inactive
adamtheturtle
temporarily deployed
to
vuforia
September 7, 2026 22:20 — with
GitHub Actions
Inactive
adamtheturtle
temporarily deployed
to
vuforia
September 7, 2026 22:20 — with
GitHub Actions
Inactive
adamtheturtle
temporarily deployed
to
vuforia
September 7, 2026 22:20 — with
GitHub Actions
Inactive
adamtheturtle
temporarily deployed
to
vuforia
September 7, 2026 22:20 — with
GitHub Actions
Inactive
adamtheturtle
temporarily deployed
to
vuforia
September 7, 2026 22:20 — with
GitHub Actions
Inactive
adamtheturtle
had a problem deploying
to
vuforia
September 7, 2026 22:20 — with
GitHub Actions
Failure
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.
Closes #3371.
The per-route validator chains (#3562) and the single database resolution (#3526) covered the applicability and route-table halves of the issue. This PR covers the remaining half: the body was still parsed by every validator which read it.
Services validators.
ValidatorContextgains two cached properties,request_jsonanddecoded_image. The JSON validators check thatrequest_jsoncan be computed and translate the failure into the route's error, and every later validator reads the parsed object rather than callingjson.loadsitself. The image validators share one base64 decode instead of four.validate_image_encodingreports a decode failure from the same cached decode the later image validators use.Query validators.
parse_multipartnow returns aMultipartFormof plain field strings and file bytes, so the parse is not tied to consumableFileStoragestreams.run_query_validatorsparses once, immediately after theContent-Typeheader validator which checks the boundary, and passes the form to the eight body validators. It returns aValidatedQueryholding the parsed form and the database whichvalidate_authorizationmatched, andget_query_match_response_texttakes that instead of re-parsing the body and re-resolving the database.validate_project_statetakes the database rather than resolving it a third time.Error precedence is unchanged. The order of every validator is as it was, and the parse for the Query API happens at the point where the first body-reading validator used to parse.
Tested locally against the non-real backends:
test_query,test_add_target,test_update_target,test_invalid_json,test_unexpected_json,test_vumark_generation_api,test_reco_counts_report,test_target_validatorsandtest_requests_mock_usageall pass.prekincluding the manualpylintstage and the pre-push type checkers passes.🤖 Generated with Claude Code