fix ResponseMetaDataTransformer#13
Conversation
| if k == "ResponseMetadata": | ||
| metadata = v | ||
| http_headers = metadata.get("HTTPHeaders") | ||
| if not isinstance(http_headers, dict): |
There was a problem hiding this comment.
Good handling of non-expected values here 👏
| # TODO "x-amz-bucket-region" | ||
| # TestS3.test_region_header_exists -> verifies bucket-region | ||
|
|
||
| # FIXME: proper value is `content-type` with no underscore in lowercase, but this will necessitate a |
There was a problem hiding this comment.
This is a big problem actually. It's not the first time that we defer fixing issues in snapshot library because of backwards compatibility. Thanks for highlighting it! I added the issue about this to snapshots library backlog.
There was a problem hiding this comment.
It does yes. Maybe versioning could actually help here? Store the snapshot library version along the snapshot, to enjoy new features / support backward compatibility. Thanks for adding the issue on the backlog.
There was a problem hiding this comment.
Yes, versioning is the option I added to the backlog issue. It is not the straightforward one when projected onto test runs as we will need to run tests with different dependency versions, but definitely something to try.
While working with API Gateway and trying to snapshot responses coming from AWS_PROXY Integration Subtypes, AWS will return a response containing the
ResponseMetadatafield but already filtered, with noHTTPHeadersfield in it.The current
ResponseMetaDataTransformerwill always try access theHTTPHeadersfield as a dict, even if the value fromhttp_headers = metadata.get("HTTPHeaders")isNone, raising this exception:As a workaround, I've implemented a hack like that:
service_resp["_ResponseMetadata"] = service_resp.pop("ResponseMetadata")This PR now properly fixes it, and adds some test for the transformer.
I'd like to note that it seems we were trying to get the
Content-Typeheader from the response, but as the value was wrong, it was never captured in any snapshots.Adding it now would need a full refresh, or a big skip, so this is out of scope of this PR.
For the release version, I'd say this could be a
0.3.1?