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

AwsServiceException is missing service error details #698

Closed
yzarubin opened this issue Oct 17, 2023 · 2 comments
Closed

AwsServiceException is missing service error details #698

yzarubin opened this issue Oct 17, 2023 · 2 comments
Labels
bug This issue is a bug. CRT/SDK p2 This is a standard priority issue

Comments

@yzarubin
Copy link

yzarubin commented Oct 17, 2023

Describe the bug

AwsServiceExceptions thrown by the CRT client are missing errorMessage and errorCode values, thus making them difficult to debug and programmatically handle.

Expected Behavior

AwsServiceException thrown by DefaultS3CrtAsyncClient should have AwsErrorDetails with correct errorCode and errorMessage values that match the vanilla client.

Example: AwsErrorDetails(errorMessage=Your key is too long, errorCode=KeyTooLongError, serviceName=S3)'

Current Behavior

AwsErrorDetails contains only the serviceName, and is missing errorCode and errorMessage

Example: AwsErrorDetails(serviceName=S3)

Reproduction Steps

  public void reproS3Error() {
    final S3AsyncClient vanillaClient = S3AsyncClient.builder()
        .region(Region.US_EAST_1)
        .credentialsProvider(Credentials.ADMIN)
        .build();

    final S3AsyncClient crtClient = S3AsyncClient.crtBuilder()
        .region(Region.US_EAST_1)
        .credentialsProvider(Credentials.ADMIN)
        .build();

    Consumer<S3AsyncClient> doRepro = (client) -> {
      byte[] buf = new byte[1025];
      Arrays.fill(buf, (byte) 1);

      try {
        client.getObject(GetObjectRequest.builder()
                .bucket(BUCKET)
                .key(new String(buf))
                .build(),
            new File("/tmp/foo").toPath()).join();
      } catch (Throwable e) {
        final AwsServiceException ex;

        if (e instanceof AwsServiceException) {
          ex = (AwsServiceException) e;
        } else if (e.getCause() != null && e.getCause() instanceof AwsServiceException) {
          ex = (AwsServiceException) e.getCause();
        } else {
          throw e;
        }

        final String clientName = client.getClass().getSimpleName();
        System.out.println(clientName + " message: '" + ex.getMessage() + "'");
        System.out.println(clientName + " awsErrorDetails: '" + ex.awsErrorDetails() + "'");
      }
    };

    doRepro.accept(vanillaClient);
    doRepro.accept(crtClient);
  }

This prints:


DefaultS3AsyncClient message: 'Your key is too long (Service: S3, Status Code: 400, Request ID: <omitted>, Extended Request ID: <omitted>'
DefaultS3AsyncClient awsErrorDetails: 'AwsErrorDetails(errorMessage=Your key is too long, errorCode=KeyTooLongError, serviceName=S3)'

DefaultS3CrtAsyncClient message: 'null (Service: S3, Status Code: 400, Request ID: <omitted>, Extended Request ID: <omitted>)'
DefaultS3CrtAsyncClient awsErrorDetails: 'AwsErrorDetails(serviceName=S3)'

Possible Solution

AwsErrorDetails should be populated with the correct values.

Additional Information/Context

No response

aws-crt-java version used

1.0.x

Java version used

21

Operating System and version

MacOS 13.4.1

@yzarubin yzarubin added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Oct 17, 2023
@TingDaoK
Copy link
Contributor

Our exception does have info with errorCode and errorMessage. https://github.com/awslabs/aws-crt-java/blob/main/src/main/java/software/amazon/awssdk/crt/s3/CrtS3RuntimeException.java#L41-L48

I guess it's Java SDK didn't transform the exception correctly

@jmklix jmklix added p2 This is a standard priority issue CRT/SDK and removed needs-triage This issue or PR still needs to be triaged. labels Oct 24, 2023
@jmklix
Copy link
Member

jmklix commented Nov 15, 2023

Fixed with latest release

@jmklix jmklix closed this as completed Nov 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. CRT/SDK p2 This is a standard priority issue
Projects
None yet
Development

No branches or pull requests

3 participants