Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AWS_REQUEST_ID_HEADER not always picked up in Display for RusotoError<E> #1993

Open
Fuuzetsu opened this issue Nov 8, 2022 · 0 comments
Open

Comments

@Fuuzetsu
Copy link
Contributor

Fuuzetsu commented Nov 8, 2022

There's a trait impl like

impl<E: Error + 'static> fmt::Display for RusotoError<E> {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        match *self {
// …
            RusotoError::Unknown(ref cause) => write!(
                f,
                "Request ID: {:?} Body: {}",
                cause.headers.get(AWS_REQUEST_ID_HEADER),
                cause.body_as_str()
            ),
// ...
        }
    }

and

/// Header used by AWS on responses to identify the request
pub const AWS_REQUEST_ID_HEADER: &str = "x-amzn-requestid";

but this isn't completely correct. For example, I sent a PutObjectRequest with md5 set to Some("fake") and in response I got:

Request ID: None Body: <?xml version="1.0" encoding="UTF-8"?>
<Error><Code>InvalidDigest</Code><Message>The Content-MD5 you specified was invalid.</Message><Content-MD5>fake</Content-MD5><RequestId>M99NXA1M3GDBERKX</RequestId><HostId>8eomc+jLMa4yGJk8BsYCCUdyd4mKVHhUA+/ILHFdcrVKMEcEbAKdnH8cAMXnDpeKkH99yqJkJis=</HostId></Error> (Unknown(BufferedHttpResponse {status: 400, body: "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Error><Code>InvalidDigest</Code><Message>The Content-MD5 you specified was invalid.</Message><Content-MD5>fake</Content-MD5><RequestId>M99NXA1M3GDBERKX</RequestId><HostId>8eomc+jLMa4yGJk8BsYCCUdyd4mKVHhUA+/ILHFdcrVKMEcEbAKdnH8cAMXnDpeKkH99yqJkJis=</HostId></Error>", headers: {"x-amz-request-id": "M99NXA1M3GDBERKX", "x-amz-id-2": "8eomc+jLMa4yGJk8BsYCCUdyd4mKVHhUA+/ILHFdcrVKMEcEbAKdnH8cAMXnDpeKkH99yqJkJis=", "content-type": "application/xml", "transfer-encoding": "chunked", "date": "Tue, 08 Nov 2022 01:57:22 GMT", "server": "AmazonS3", "connection": "close"} })) (should_retry: false)

You'll notice how the header is x-amz-requestid so the Display instance fails to pick it up and shows None.

I noticed that some API docs such as https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-logging-variables.html specify that it can be either one:

The AWS endpoint's request ID from the x-amz-request-id or x-amzn-requestId header.
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

No branches or pull requests

1 participant