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

Improve error message when checksum validation fails. Make such failures retryable. #2798

Merged
merged 1 commit into from
Oct 26, 2021

Conversation

millems
Copy link
Contributor

@millems millems commented Oct 25, 2021

No description provided.

String.format("Data read has a different checksum than expected. Was 0x%s, but expected 0x%s. "
+ "Common causes: (1) You modified a request ByteBuffer before it could be "
+ "written to the service. Please ensure your data source does not modify the "
+ " byte buffers you pass to the SDK. (2) The data was corrupted between the client and "
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Should we clarify to not modify after passing to the SDK?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

throw RetryableException.create(
String.format("Data read has a different checksum than expected. Was 0x%s, but expected 0x%s. " +
"This commonly means that the data was corrupted between the client and " +
"service. Please retry your request.",
Copy link
Contributor

Choose a reason for hiding this comment

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

We have 3 slightly different wordings for this. Should they all be the same? Should we vend a consistent error message from a util method?

Copy link
Contributor Author

@millems millems Oct 26, 2021

Choose a reason for hiding this comment

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

There's 2 wordings. One includes the byte buffer being modified because that's a potential cause. The other two places do not have this risk, so it excludes that as a potential cause.

Copy link
Contributor

Choose a reason for hiding this comment

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

Got it. As a nit: one wording said to "please retry", and the other did not.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, good catch! I meant to remove "please retry", because we should just retry instead of asking them to do it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

onError(SdkClientException.create(
String.format("Data read has a different checksum than expected. Was 0x%s, but expected 0x%s",
onError(RetryableException.create(
String.format("Data read has a different checksum than expected. Was 0x%s, but expected 0x%s. "
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Out of scope of this change, but also consider "expected X, but was Y" -- this follows the traditional unit test style wording.

@millems millems force-pushed the millem/improve-checksum-exception branch 2 times, most recently from eb80efe to 947d576 Compare October 26, 2021 00:09
@millems millems force-pushed the millem/improve-checksum-exception branch from 947d576 to a5de2cd Compare October 26, 2021 00:20
@sonarqubecloud
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

100.0% 100.0% Coverage
0.0% 0.0% Duplication

@millems millems merged commit 5af29f8 into master Oct 26, 2021
@millems millems deleted the millem/improve-checksum-exception branch October 19, 2022 19:38
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.

2 participants