aws / aws-sdk

Landing page for the AWS SDKs on GitHub
https://aws.amazon.com/tools/
Other
68 stars 12 forks source link

Synthetics `ResourceNotFoundException` is not being typed correctly #695

Closed johnsonaj closed 3 months ago

johnsonaj commented 4 months ago

Describe the bug

When calling GetCanary on a non-existent resource the type is not being returned correctly if the resource does not exist. However, when looking at the err.Error(), the correct error information is in the string.

Expected Behavior

when asserting the ResourceNotFoundException error as a type, it should correctly serialize as types.ResourceNotFoundException

var nfe *types.ResourceNotFoundException
if errors.As(err, &nfe) {
 . . .
}

Current Behavior

Type is not correctly serialized. err.Error() contains all of the correct information.

GetCanary, https response error StatusCode: 404, RequestID: a42c8de2-d838-4ce8-a2a5-8456539b6075, api error ResourceNotFoundException: Canary not found."

Reproduction Steps

Call synthetics.GetCanary() with a resource that does not exist

Possible Solution

No response

Additional Information/Context

No response

AWS Go SDK V2 Module Versions Used

github.com/aws/aws-sdk-go-v2/service/synthetics v1.22.7

Compiler and Version used

go version go1.21.6 darwin/arm64

Operating System and version

MacOS Sonoma 14.3

lucix-aws commented 4 months ago

May be the same underlying issue as https://github.com/aws/aws-sdk-go-v2/issues/2476. Can you provide the raw error response body?

johnsonaj commented 4 months ago

May be the same underlying issue as aws/aws-sdk-go-v2#2476. Can you provide the raw error response body?

@lucix-aws Does this work?

request failed with unretryable error https response error StatusCode: 404, RequestID: c1cf4ca4-1875-495d-91c2-75a627a5dc26, api error ResourceNotFoundException: Canary not found.

or

operation error synthetics: GetCanary, https response error StatusCode: 404, RequestID: 2f77b795-fcca-4c0e-aa9e-1db082b4614e, api error ResourceNotFoundException: Canary not found.
RanVaknin commented 4 months ago

Hi @johnsonaj ,

The reason the error is not being populated with the correct type, is because its not listed as a valid error in the server's specification. You can see that according to the docs for getCanary() only expects two types of modeled errors:

image

This is also specified in the API model for the service here , and therefore the SDK's error deserializer would not generate a case for that as seen here.

So while the error gets correctly deserialized, the SDK doesn't "know" that getCanary can return said excpetion, and just turns it into a generic smithy error.

I'll review this with the team and see if this is something we can solve with the service team itself.

Thanks, Ran~

RanVaknin commented 4 months ago

I created an internal ticket with the service team to fix this P117442165.

Transferring to the Cross-SDK repo for further tracking.

Thanks again, Ran~

RanVaknin commented 3 months ago

Hi there, I have received confirmation that this is the service team's backlog. Since this is not something the SDK team can address I'm going to go ahead and close this.

Thanks again for reporting this. Ran~

github-actions[bot] commented 3 months ago

This issue is now closed.

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.