Factor out repeated validator exception response construction - #3454
Open
adamtheturtle wants to merge 1 commit into
Open
Factor out repeated validator exception response construction#3454adamtheturtle wants to merge 1 commit into
adamtheturtle wants to merge 1 commit into
Conversation
The validator exception modules were 1658 lines for 44 classes, almost all of it the same three steps repeated: build a result code body, format a Date header, and write out an otherwise identical header dict. That made the header values expensive to change and buried the two facts worth reading about each class - its status code and its result code. Move the repeated values into module level header constants which each class merges with its Date and Content-Length, and share the transaction ID body and the Date formatting between the two modules. The modules keep separate constants, as the services and query APIs send different headers. This is a pure refactor: the status codes, result codes, bodies and header values are unchanged. Header ordering within the dicts differs, which the tests allow, as they compare header names as a set. Co-Authored-By: Claude Opus 5 (1M context) <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.
Closes #3389.
The two validator exception modules were 1658 lines for 44 classes, nearly all of it the same three steps repeated per class: build a
transaction_id/result_codebody, format aDateheader, and write out an otherwise identical header dict. This moves the repeated header values into module level constants which each class merges with its ownDateandContent-Length, and shares the body construction andDateformatting between the two modules via_mock_common, taking them to 1006 lines. The modules keep separate constants because the services and query APIs genuinely send different headers, and no inheritance is introduced --ValidatorErrorremains an attribute-only marker and each class still builds its own response explicitly.This is a pure refactor: every status code, result code, body and header value is unchanged, so
x-aws-region,server,strict-transport-securityandx-envoy-upstream-service-timeeach become a one line edit for #3365. Header ordering within the dicts differs, which the existing tests allow as they compare header names as a set.🤖 Generated with Claude Code