itty-aws icon indicating copy to clipboard operation
itty-aws copied to clipboard

error codes for awsQuery protocol don't match error structure name

Open kmitchener opened this issue 4 months ago • 1 comments

Raw error code response from AWS uses <Code> element such as "NoSuchEntity" which doesn't match what we're extracting as the error type "NoSuchEntityException".

<ErrorResponse xmlns="https://iam.amazonaws.com/doc/2010-05-08/">
  <Error>
    <Type>Sender</Type>
    <Code>NoSuchEntity</Code>
    <Message>The user with name itty-aws-test-user cannot be found.</Message>
  </Error>
  <RequestId>67c5e7e6-8119-4205-8d38-db0207d2c420</RequestId>
</ErrorResponse>

Smithy model:

    "com.amazonaws.iam#NoSuchEntityException": {
      "type": "structure",
      "members": {
        "message": {
          "target": "com.amazonaws.iam#noSuchEntityMessage"
        }
      },
      "traits": {
        "aws.protocols#awsQueryError": {
          "code": "NoSuchEntity",
          "httpResponseCode": 404
        },
        "smithy.api#documentation": "<p>The request was rejected because it referenced a resource entity that does not exist. The\n      error message describes the resource.</p>",
        "smithy.api#error": "client",
        "smithy.api#httpError": 404
      }
    },

kmitchener avatar Aug 30 '25 11:08 kmitchener

This should match the error code in the AWS docs / AWS clients: https://docs.aws.amazon.com/IAM/latest/APIReference/API_DeletePolicy.html

We are matching the Exception name as the other AWS clients, including aws-sdk-v3, so the error type name is correct in itty-aws, but the dynamic creation of the error is using the "code" returned by the raw API response, which is incorrect.

kmitchener avatar Aug 30 '25 14:08 kmitchener