Repository navigation
Keep the HTTP status and response body in fallback errors - #10
Merged
Merged
Conversation
Since the error-handler module was disabled (c790cb8), every HTTP failure reaches the fallbacks as jclouds' HttpResponseException, which carries the response and its body. The fallbacks parsed only the exception's message ("command: GET ... failed with response: HTTP/1.1 404 ...; content: [...]"), so even Bitbucket's own JSON errors came back as "Failed to parse output ... MalformedJsonException", and callers had to guess the status from that text. - Error gains a nullable statusCode: the HTTP status of the failed response, or null when there was no response (e.g. a timeout). - BitbucketFallbacks.getErrors(Throwable) finds the HttpResponseException in the cause chain, parses its response body (the message when there is none, as before) and sets the status on every error. All fallbacks use it; RawContentOnError sets the status too. - check now runs mockTest, so the publish job tests what it releases. Four mock tests that failed on master pass with this change. - Version 3.1.4-CORTEX. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
mmaikel
marked this pull request as ready for review
October 1, 2026 11:27
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.
Why
Since the error-handler module was commented out (c790cb8, 2023), every HTTP failure reaches the fallbacks as jclouds'
HttpResponseException(fromCloseContentAndSetExceptionErrorHandler). That exception carries the response (getResponse().getStatusCode()) and its body (getContent()), but every fallback parsed onlythrowable.getMessage():That text is not JSON, so even Bitbucket's own errors came back as
Failed to parse output: … MalformedJsonException, with the status lost. brain-backend has been guessing it from that text (regexes onstatusCode=, "does not exist at revision", "a status-less MalformedJsonException is a 404"), and the guesses misfire in prod: tenant 1782 gets ~11k "Could not find repo" a day for repositories that answer 200 (CD-606 follow-up).What
Error.statusCode()(nullable): the HTTP status of the failed response; null when there was no response (timeout, connection reset). The existing 5-argumentError.createstays, so callers compile unchanged.BitbucketFallbacks.getErrors(Throwable): finds theHttpResponseExceptionin the cause chain, parses its response body (falling back to the message when there is no body, as before), and sets the status on every error. All 51 fallbacks use it;RawContentOnErrorsets the status too.checknow runsmockTest. CI only rancheck, which ran no tests, so the published jar was untested; four mock tests were failing onmasterfor exactly this bug (testListBranchesNonExistent,testGetPullRequestNonExistent,testCreatePullRequestEmpty,testMergePullRequestNeedsRetry) and pass now.3.1.4-CORTEX(GitHub Packages does not overwrite a published version).Not changed: re-binding
BitbucketErrorHandler. It is dead code since 2023, and binding it would change which exception types every call throws.Tests
Mock tests through the real jclouds stack (
MockWebServer):listLines404 with Bitbucket's JSON errorlistLines404 with an HTML bodylistLines503 without a bodylistLines200 with an unreadable bodygetDefault404 for a missing repositorygetDefaultrelay 555raw404Unit: a failure without a response has no status; a wrapped
HttpResponseExceptionkeeps its status../gradlew check(JDK 17): 265 mock tests, 0 failures.Follow-up
brain-backend: bump to
3.1.4-CORTEX, classify byError.statusCode()(404 = not found, 555 = relay unavailable) and drop the text heuristics.🤖 Generated with Claude Code