Repository navigation
Read the error response body when the auth endpoint returns an error status - #382
Conversation
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #382 +/- ##
============================================
+ Coverage 74.65% 76.26% +1.60%
- Complexity 363 379 +16
============================================
Files 48 48
Lines 1965 1976 +11
Branches 145 151 +6
============================================
+ Hits 1467 1507 +40
+ Misses 433 405 -28
+ Partials 65 64 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Thanks, this looks good, and the response body is the missing piece for debugging auth failures. One request before we merge. Today, for an error status, the message has the status and URL but not the body: With this change, it has the body but loses the status and URL: Could the message keep all three? For example: The fallback when the body is empty could include the URL the same way, so the two messages match. |
|
Done in e8a9cb4. The message now keeps the status and URL, and appends the body when there is one: With an empty body, it ends after the URL: The existing tests now check the full message, and a new test in |
|
Thanks for the quick turnaround, and for adding the empty-body tests. |
What does this PR do?
Fixes #261.
When the channel authorization or user authentication endpoint responds with a status of 400 or above,
HttpURLConnection.getInputStream()throws (FileNotFoundExceptionfor 404,IOException: Server returned HTTP response code: 403 ...for other codes). The response body the server sent is lost, and the status check that follows the read never runs for these codes. The resultingAuthorizationFailureExceptionorAuthenticationFailureExceptiononly carries the URL and status, not the reason the server gave.This change in
BaseHttpAuthClient:getErrorStream()for statuses of 400 and above.Server returned HTTP response code: <status>when the error response has no body.Successful responses are handled as before. New tests in
HttpChannelAuthorizerTestandHttpUserAuthenticatorTeststart a localHttpServerthat returns 403 with a JSON body and check that the exception message is that body. Both tests fail onmasterand pass with this change.CHANGELOG