Conversation
When getErrorStream() returns null for a 401 response (no body), the previous fallback called getInputStream() which throws IOException for non-2xx status codes. That IOException was caught and wrapped as an ApiConnectionException, hiding the 401 from HttpClient.shouldRetry(), so refreshToken() was never called and the OAuth token was never refreshed — causing the client to exhaust all retries until restart. Fix: for error status codes (non-2xx) where getErrorStream() returns null, return an AtlanResponseStream with an empty ByteArrayInputStream instead of calling getInputStream(). This preserves the HTTP status code so the 401 is visible to shouldRetry() and triggers the OAuth refresh as intended. Reproducer: Guidewire purging ~12k assets hit the ~10-min token expiry boundary (Zendesk #119550). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Chris (He/Him) <cgrote@gmail.com>
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
HttpURLConnectionClient.requestStream(), whengetErrorStream()returnsnullfor a non-2xx response (e.g. a 401 with no body), the fallback calledgetInputStream()— which throwsIOExceptionfor 4xx/5xx status codes. That exception was caught and wrapped asApiConnectionException, hiding the status code fromHttpClient.shouldRetry()sorefreshToken()was never called.getErrorStream()isnull, return anAtlanResponseStreamwith an emptyByteArrayInputStream. This preserves the HTTP status code so the 401 reachesshouldRetry()and triggers the OAuth token refresh as intended.HttpURLConnectionClientTest) that stubs a 401 with no body and asserts the response code is 401 (not an exception).Customer impact
Guidewire reproduced this while purging ~12k assets; 401s occur at the ~10-minute token expiry boundary (Zendesk #119550).
Test plan
testOAuth401WithNoBodyReturnsResponseCodepassesspotlessApplyformatting applied🤖 Generated with Claude Code