Skip to content

Attach response metadata to operation outputs and errors, escaping collisions - #794

Open
ubaskota wants to merge 1 commit into
smithy-lang:developfrom
ubaskota:response_metadata_impl
Open

Attach response metadata to operation outputs and errors, escaping collisions#794
ubaskota wants to merge 1 commit into
smithy-lang:developfrom
ubaskota:response_metadata_impl

Conversation

@ubaskota

Copy link
Copy Markdown
Contributor

Issue #, if available:

Description of changes:
Response metadata was previously discarded. Every operation output and modeled error now carries a response_metadata attribute holding the request ID, extended request ID, and HTTP status code of the response that produced it. It is always present, so callers need no null check; an http_status_code of None records that no response arrived.

Codegen writes the field into each generated output class, since outputs share no base class. Modeled errors inherit it from CallError instead. extract_response_metadata() is added to ClientProtocol and called once per call from _execute_request, on the path both successes and errors pass through, so each protocol decides where the identifiers live. AWS protocols read response headers, awsQuery reads the response body.

Services that already model a member named responseMetadata on an output or error have it renamed to response_metadata_ so the two cannot collide. Only the Python attribute changes; the wire format is untouched.

Testing:

  • All unit tests and protocol tests pass
  • Built a test service modelling responseMetadata on an output, an error and an input. Verified that codegen escaped the output and error members to response_metadata_ and left the input untouched.
  • Ran the generated client against a fake transport and confirmed the service's own value and the attached metadata both survived, on the success and error paths.
  • Exercised awsQuery end to end with no request-ID headers, so the identifier could only come from the body. Verified it was reported on both response shapes: nested under ResponseMetadata on success, and directly under the root element on failure.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@ubaskota
ubaskota requested a review from a team as a code owner September 11, 2026 04:29
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.

1 participant