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

Adds support for parsing errors with a top level root XML structure #2060

Closed
wants to merge 1 commit into from

Conversation

cenedhryn
Copy link
Contributor

Description

  • Adds an interceptor to modify a generic unmarshalled S3ControlException when the message contains 'null' and the XML body contains 'Error' as the top level element. The interceptor will attempt to identify a modeled exception if it exists, otherwise return a new S3ControlException with message/error code correctly filled in.
  • Supports InvalidRequestException
  • Detected and tracked in Incomplete Field Mapping for S3ControlException via S3ControlClient.createJob() #1986

Motivation and Context

Errors from the server side that contain an XML body with error description should have this structure:

<ErrorResponse>
  <Error>
    <AccountId></AccountId>
    <Code></Code>
    <Message></Message>
  </Error>
</ErrorResponse>

However at least one error type, InvalidRequest, that S3Control returns (observed through the Jobs CRUD operations) use the S3-structure with no wrapping top level tag:

  <Error>
    <AccountId></AccountId>
    <Code></Code>
    <Message></Message>
  </Error>

The error parser that S3 control uses cannot parse the XML document with the Error as the document root and therefore creates an exception with no information.

Testing

Added wiremock tests and integration tests, verified that existing errors unmarshall correctly.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • I have read the CONTRIBUTING document
  • Local run of mvn install succeeds
  • My code follows the code style of this project
  • My change requires a change to the Javadoc documentation
  • I have updated the Javadoc documentation accordingly
  • I have read the README document
  • I have added tests to cover my changes
  • All new and existing tests passed
  • A short description of the change has been added to the CHANGELOG
  • My change is to implement 1.11 parity feature and I have updated LaunchChangelog

License

  • I confirm that this pull request can be released under the Apache 2 license

@cenedhryn cenedhryn force-pushed the salande/s3control-exception-unmarshalling branch 2 times, most recently from b86fe87 to a1d839f Compare September 23, 2020 21:35
@codecov-commenter
Copy link

codecov-commenter commented Sep 23, 2020

Codecov Report

Merging #2060 into master will decrease coverage by 1.03%.
The diff coverage is 93.75%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #2060      +/-   ##
============================================
- Coverage     78.35%   77.32%   -1.04%     
- Complexity      153      235      +82     
============================================
  Files            22     1137    +1115     
  Lines           804    34879   +34075     
  Branches         32     2728    +2696     
============================================
+ Hits            630    26971   +26341     
- Misses          167     6554    +6387     
- Partials          7     1354    +1347     
Flag Coverage Δ Complexity Δ
#unittests 77.32% <93.75%> (-1.04%) 235.00 <8.00> (+82.00) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ Complexity Δ
...n/awssdk/http/FileStoreTlsKeyManagersProvider.java 100.00% <ø> (ø) 5.00 <0.00> (?)
...sdk/http/SystemPropertyTlsKeyManagersProvider.java 93.75% <ø> (ø) 7.00 <0.00> (?)
...rnal/interceptors/TopLevelXMLErrorInterceptor.java 93.33% <93.33%> (ø) 8.00 <8.00> (?)
.../http/AbstractFileStoreTlsKeyManagersProvider.java 100.00% <100.00%> (ø) 3.00 <0.00> (?)
...ed/dynamodb/mapper/StaticImmutableTableSchema.java 88.55% <100.00%> (ø) 0.00 <0.00> (?)
...on/awssdk/codegen/lite/regions/model/Endpoint.java 17.89% <0.00%> (-15.44%) 0.00% <0.00%> (-8.00%)
...wssdk/http/nio/netty/internal/ResponseHandler.java 89.30% <0.00%> (ø) 0.00% <0.00%> (?%)
.../awssdk/codegen/poet/model/BaseExceptionClass.java 100.00% <0.00%> (ø) 0.00% <0.00%> (?%)
...awssdk/core/retry/conditions/OrRetryCondition.java 65.00% <0.00%> (ø) 0.00% <0.00%> (?%)
...oftware/amazon/awssdk/services/s3/S3Utilities.java 92.45% <0.00%> (ø) 0.00% <0.00%> (?%)
... and 1111 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d0c22e8...a1d839f. Read the comment docs.

@cenedhryn cenedhryn force-pushed the salande/s3control-exception-unmarshalling branch from a1d839f to 8425865 Compare September 23, 2020 23:10
@sonarcloud
Copy link

sonarcloud bot commented Sep 23, 2020

SonarCloud Quality Gate failed.

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 2 Code Smells

54.5% 54.5% Coverage
5.3% 5.3% Duplication

warning The version of Java (1.8.0_252) you have used to run this analysis is deprecated and we will stop accepting it from October 2020. Please update to at least Java 11.
Read more here

Comment on lines +54 to +58
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>aws-query-protocol</artifactId>
<version>${awsjavasdk.version}</version>
</dependency>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a new dependency, or has it always been there?

Copy link
Contributor Author

@cenedhryn cenedhryn Sep 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a new dependency, on the XmlDomParser

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately it's not backwards-compatible to add new dependencies on existing packages, since it causes Brazil major version conflicts. Is there any way to avoid this new dependency?

Comment on lines +29 to +31
* Translate S3 style exceptions, which have the Error tag at root instead of wrapped in ErrorResponse.
* If the exception follows this structure but isn't known, create an S3ControlException with the
* error code and message.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this already implemented in the S3 client?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In S3 the whole client is customized to use the AwsS3ProtocolFactory instead of AwsXmlProtocolFactory. It's not possible to use it dynamically for one or two exception types.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we not use the AwsS3ProtocolFactory for all exception types?

Comment on lines +31 to +32
log4j.logger.org.apache.http=DEBUG
log4j.logger.org.apache.http.wire=DEBUG
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a lot of logging for the default.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed. Good catch, in a previous incarnation it was commented out but missed it in following commits.

@cenedhryn cenedhryn closed this Apr 29, 2021
@cenedhryn
Copy link
Contributor Author

Superceded by a different PR

aws-sdk-java-automation added a commit that referenced this pull request Jun 16, 2022
…4bd73861b

Pull request: release <- staging/c25e67e9-b2b6-46b4-b4cf-63d4bd73861b
@cenedhryn cenedhryn deleted the salande/s3control-exception-unmarshalling branch September 9, 2022 18:52
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

Successfully merging this pull request may close these issues.

None yet

3 participants