Skip to content

Factor out repeated validator exception response construction - #3454

Open
adamtheturtle wants to merge 1 commit into
mainfrom
adamtheturtle/issue-3389-no-inheritance
Open

Factor out repeated validator exception response construction#3454
adamtheturtle wants to merge 1 commit into
mainfrom
adamtheturtle/issue-3389-no-inheritance

Conversation

@adamtheturtle

Copy link
Copy Markdown
Member

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_code body, format a Date header, and write out an otherwise identical header dict. This moves the repeated header values into module level constants which each class merges with its own Date and Content-Length, and shares the body construction and Date formatting 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 -- ValidatorError remains 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-security and x-envoy-upstream-service-time each 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

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1658 lines of validator exceptions differ mostly by two values

1 participant