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

feat: handle S3 error responses with HTTP 200 status code #1117

Merged
merged 5 commits into from
Nov 21, 2023
Merged

Conversation

aajtodd
Copy link
Collaborator

@aajtodd aajtodd commented Nov 17, 2023

Issue #

fixes #199

Description of changes

Adds an interceptor that attempts to parse the response XML as an error response and resets the HTTP status code accordingly to trigger error handling.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@aajtodd aajtodd requested a review from a team as a code owner November 17, 2023 20:57
Copy link

A new generated diff is ready to view.

import kotlin.test.assertEquals
import kotlin.test.assertFailsWith

class Handle200ErrorsInterceptorTest {
Copy link
Member

Choose a reason for hiding this comment

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

You could also add a test ensuring error payloads are unmodified (tests L27 of your interceptor if (!response.status.isSuccess()) return response)

Comment on lines 52 to 53
assertEquals(expectedMessage, ex.sdkErrorMetadata.errorMessage)
assertEquals(expectedMessage, ex.sdkErrorMetadata.errorMessage)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit:

Double line.
Double line.

Comment on lines +24 to +25
override fun enabledForService(model: Model, settings: KotlinSettings): Boolean =
model.expectShape<ServiceShape>(settings.service).isS3
Copy link
Contributor

Choose a reason for hiding this comment

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

Question: Should this apply to any other S3-adjacent services like S3 Control, Glacier, etc.?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is a good question, I actually think several of our customizations may need to apply to both s3 and s3 control. Not 100% on which ones though.

Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

Copy link

A new generated diff is ready to view.

@aajtodd aajtodd merged commit 7b3d0cb into main Nov 21, 2023
16 of 17 checks passed
@aajtodd aajtodd deleted the s3-200-errors branch November 21, 2023 14:23
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.

S3 Customization to handle status code 200 Errors
3 participants