Skip to content

AWSError can not marshall or parse service errors #646

Closed

Description

@diablodale

Setup

Windows x64 debug compiling with VS2015 toolchain (v140) for target=Windows 8.1
AWS SDK v1.1.26 and v1.1.42 both with static linking

Repro

Create a simple app that uses the PutObjectRequest model to send a single file into an S3 bucket/key.
When setting .WithBucket() and .WithKey(), use empty c-strings for both params.
Send the files with FStream and binary.
Set the body to the FStream
Then ->PutObject(myPutObjectRequest)

You will get an error because the bucket and keys are empty strings.
Examine or output the ExceptionName and Message of the AWSError. For example:

printf("put %s %s", put_object_outcome.GetError().GetExceptionName().c_str(), put_object_outcome.GetError().GetMessage().c_str());

Result

The message is degraded. As can be seen below in the live memory examination and the AWS logging, the error was very parse-able. The exception name is good. The AWSError had all the data it needed for a good parse. Yet, the error handling codebase degraded the message by concatenating together what it already knows unto a mixed message.

return AWSError<CoreErrors>(CoreErrors::UNKNOWN, exceptionName, "Unable to parse ExceptionName: " + exceptionName + " Message: " + message, false);

The in-memory AWSError object is:

m_errorType=UNKNOWN (100)
m_exceptionName="MethodNotAllowed"
m_message="Unable to parse ExceptionName: MethodNotAllowed Message: The specified method is not allowed against this resource."
m_responseCode = METHOD_NOT_ALLOWED (405)
m_isRetryable = false

Aws::Utils::Logging has the following:

[DEBUG] 2017-09-01 23:47:43 WinHttpSyncHttpClient [13360] Received response code 405
[DEBUG] 2017-09-01 23:47:43 WinHttpSyncHttpClient [13360] Received content type application/xml
[DEBUG] 2017-09-01 23:47:43 WinHttpSyncHttpClient [13360] Received headers:
[DEBUG] 2017-09-01 23:47:43 WinHttpSyncHttpClient [13360] HTTP/1.1 405 Method Not Allowed
Connection: close
Date: Fri, 01 Sep 2017 21:47:43 GMT
Transfer-Encoding: chunked
Allow: GET
Content-Type: application/xml
Server: AmazonS3
x-amz-request-id: xxxxxxxxxxxxx
x-amz-id-2: xxxxxxxxxxxxxxxx
[DEBUG] 2017-09-01 23:47:43 WinHttpSyncHttpClient [13360] Closing http request handle 000000001AA66280
[DEBUG] 2017-09-01 23:47:43 WinHttpSyncHttpClient [13360] Releasing connection handle 00000000173A5240
[DEBUG] 2017-09-01 23:47:43 WinHttpConnectionPoolMgr [13360] Releasing connection to endpoint s3.amazonaws.com:443
[DEBUG] 2017-09-01 23:47:43 AWSClient [13360] Request returned error. Attempting to generate appropriate error codes from response
[TRACE] 2017-09-01 23:47:43 AWSErrorMarshaller [13360] Error response is <?xml version="1.0"?>
<?xml version="1.0" encoding="UTF-8"?>
<Error>
    <Code>MethodNotAllowed</Code>
    <Message>The specified method is not allowed against this resource.</Message>
    <Method>PUT</Method>
    <ResourceType>SERVICE</ResourceType>
    <RequestId>E45CDB5B278FEF8A</RequestId>
    <HostId>hwK+FSpErNSKd6+p58ujfPGJYJFtiZexC4e+Gr0aHtAvZEgvBmb9Tcki75ut+s0BgeqFodo5z+8=</HostId>
</Error>
[WARN] 2017-09-01 23:47:43 AWSErrorMarshaller [13360] Encountered Unknown AWSError
MethodNotAllowed
The specified method is not allowed against this resource.:
[WARN] 2017-09-01 23:47:43 AWSClient [13360] If the signature check failed. This could be because of a time skew. Attempting to adjust the signer.
[DEBUG] 2017-09-01 23:47:43 AWSClient [13360] Server time is Fri, 01 Sep 2017 21:47:43 GMT, while client time is Fri, 01 Sep 2017 21:47:43 GMT

Activity

  1. singku commented on Apr 16, 2019

    @singku
    Contributor

    UNKNOWN is a service level agreement that the error is unknown, there is no need to parse the error message. Some services emits this error type with parsable message means they should have emitted a meaningful error type. They simply didn't follow the agreement.

    Anyway, we have blocked this kind of http requests from client side with meaningful error if field is required.

    Closing if you have further question.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature-requestA feature should be added or improved.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions