Conversation
| LOGGER.warning(() -> format( | ||
| "Renamed member %s to \"%s\" because \"%s\" is reserved for response metadata.", | ||
| shape.getId(), | ||
| escapeWord(CodegenUtils.RESPONSE_METADATA_MEMBER), | ||
| CodegenUtils.RESPONSE_METADATA_MEMBER)); |
There was a problem hiding this comment.
nit: could we make this a little more explicit that the generated Python name is being escaped because response_metadata is reserved for SDK response metadata?
| LOGGER.warning(() -> format( | |
| "Renamed member %s to \"%s\" because \"%s\" is reserved for response metadata.", | |
| shape.getId(), | |
| escapeWord(CodegenUtils.RESPONSE_METADATA_MEMBER), | |
| CodegenUtils.RESPONSE_METADATA_MEMBER)); | |
| LOGGER.warning(() -> format( | |
| "Escaped generated Python name for Smithy member %s from \"%s\" to \"%s\" because \"%s\" is reserved for SDK response metadata.", | |
| shape.getId(), | |
| CodegenUtils.RESPONSE_METADATA_MEMBER, | |
| escapeWord(CodegenUtils.RESPONSE_METADATA_MEMBER), | |
| CodegenUtils.RESPONSE_METADATA_MEMBER)); |
| } | ||
|
|
||
| @Test | ||
| public void testResponseMetadataIsEscapedOnOutputsAndErrors() { |
There was a problem hiding this comment.
Should we also add a small codegen assertion for this too? This covers the symbol provider name change but an integration assertion could verify that a generated output shape contains both the escaped modeled member and the SDK reserved response_metadata field.
| @@ -0,0 +1,4 @@ | |||
| { | |||
| "type": "breaking", | |||
There was a problem hiding this comment.
Should we also call out a breaking change for the generated name change in the codegen changelog since this is also a generated SDK surface change?
Maybe something like:
"Generated operation outputs and errors now reserve response_metadata for SDK response metadata. Modeled responseMetadata members on those shapes are generated as response_metadata_."
Issue #, if available:
Description of changes:
Response metadata was previously discarded. Every operation output and modeled error now carries a
response_metadataattribute 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; anhttp_status_codeofNonerecords that no response arrived.Codegen writes the field into each generated output class, since outputs share no base class. Modeled errors inherit it from
CallErrorinstead.extract_response_metadata()is added toClientProtocoland 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
responseMetadataon an output or error have it renamed toresponse_metadata_so the two cannot collide. Only the Python attribute changes; the wire format is untouched.Testing:
responseMetadataon an output, an error and an input. Verified that codegen escaped the output and error members toresponse_metadata_and left the input untouched.ResponseMetadataon 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.