Repository navigation
Answer 502, not 500, when upstream's 2xx batch body cannot be used [patch] - #104
Merged
Merged
Conversation
…atch]
BatchAsync parsed a successful batch response with no try/catch, so a sign-in
or SSO page served with 200 threw JsonException and the client got a bare
500. BatchRewriter read oid, size, href and header values with GetValue<T>,
so a field of the wrong type ("size": "123") threw InvalidOperationException
and also surfaced as a 500.
The rewriter now reads those fields through JsonValues and type checks, and
throws JsonException for a malformed entry, which can neither be rewritten
nor passed through with upstream's credentials still in it. BatchAsync turns
a JsonException from the parse or the rewrite into a 502, the same answer a
null body already got.
Fixes #81
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Md2Tr7FWcbqPdwq2BjeG79
|
This was referenced Oct 8, 2026
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.



Fixes #81
What was wrong
ObjectRouteHandler.BatchAsyncparsed a 2xx batch body with no try/catch. When a forge sign-in page, an SSO interstitial, or a captive portal answered with200 text/html, the parser threwJsonExceptionand git-lfs got a bare 500.BatchRewriterreadoid,size, the actionhref, and header values withGetValue<T>. A field of the wrong type, such as"size": "123", threwInvalidOperationException, which also surfaced as a 500.Both are upstream sending something the proxy can't use. Answering 500 points operators at the proxy as the broken component.
Change
BatchRewriternow reads these fields throughJsonValueswith type checks. A malformed entry throwsJsonException; this is documented onRewrite. Such an entry can't be rewritten, and passing it through untouched would hand the client upstream'sheadercredentials, so the whole response is refused rather than the entry being skipped.BatchAsyncturns aJsonExceptionfrom either the parse or the rewrite into a 502, the same answer anullbody already got.Tests
ProxyFlowTests.Batch_UpstreamSuccessThatCannotBeUsed_IsABadGatewaysends three upstream bodies through the stub and checks each gets a 502: a 200text/htmlpage,"size": "123", and a numeric header value.StubUpstream.BatchSuccessBodyis a new hook that lets the stub return a raw 2xx body.BatchRewriterTests.Rewrite_FieldOfTheWrongType_IsRefusedAsMalformedcovers a numericoid, a stringsize, a fractionalsize, a numerichref, and a numeric header value.With the fix reverted, all 8 new cases fail. The full suite passes locally: 362 tests, 0 failed.
This branch touches
ObjectRouteHandler.csin a different method from #101, and merges cleanly with #101, #102 and #103.🤖 Generated with Claude Code
https://claude.ai/code/session_01Md2Tr7FWcbqPdwq2BjeG79
Generated by Claude Code