-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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 handling of invalid leg reference #5784
Improve handling of invalid leg reference #5784
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## dev-2.x #5784 +/- ##
=============================================
+ Coverage 67.81% 67.86% +0.04%
- Complexity 16531 16543 +12
=============================================
Files 1906 1906
Lines 72277 72295 +18
Branches 7443 7444 +1
=============================================
+ Hits 49016 49062 +46
+ Misses 20740 20713 -27
+ Partials 2521 2520 -1 ☔ View full report in Codecov by Sentry. |
var input = new ByteArrayInputStream(buf); | ||
byte[] serializedLegReference; | ||
try { | ||
serializedLegReference = Base64.getUrlDecoder().decode(legReference); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of interest: are you supposed to create a new decoder for every call or can you re-use the instance? (Doesn't make a difference for the review of this PR)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Base64.getUrlDecoder() returns a thread-safe singleton instance.
I had second thoughts about the log severity for incompatible serialized leg format: while an error in base64 encoding is almost certainly a client error and should be logged at INFO level, an incompatible serialized format is likely to be a deployment issue that should be logged at higher severity. WARN sounds more appropriate. |
Summary
When OTP fails to base64-decode an invalid serialized leg reference, this is currently reported as a server error with the following error message :
This PR ensures that the response returns an empty result and the decoding error is reported at INFO level in the logs.
Issue
No
Unit tests
Added unit tests.
Documentation
No