Repository navigation
Refuse a locks/batch ref that is not an object with 400 instead of 500 [patch] - #102
Merged
Merged
Conversation
…0 [patch] LockFanOutRequest.TryParse read the ref with root["ref"]?["name"], and JsonNode's string indexer throws InvalidOperationException when the node is a string, number, bool or array. Nothing caught it, so a client that sent "ref": "refs/heads/main" got an unhandled 500. The ref is now read with a type check. A ref that is present but not an object refuses the whole body, matching the parser's rule that every malformed shape is refused, so a lock is never taken without the ref the client meant to send. Fixes #77 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 #77
What was wrong
LockFanOutRequest.TryParseread the ref withroot["ref"]?["name"]. Whenrefis a string, number, bool or array, JsonNode's string indexer throwsInvalidOperationException. Nothing in the pipeline caught that exception, soPOST locks/batchwith"ref": "refs/heads/main"returned an unhandled 500 instead of a 400.Change
TryReadRefhelper checks thatrefis aJsonObjectbefore it readsname. A missing ref is still treated as no ref.refthat is present but not an object now refuses the whole body. This follows the parser's documented rule that "every malformed shape is refused", so a lock is never taken without the ref the client meant to send.{"ref": {"name": "refs/heads/main"}}behaves exactly as before.Tests
LockFanOutRequestTestsadds the first unit tests forLockFanOutRequest. They cover a ref object, an absent ref, and a ref given as a string, number, bool or array. With the fix reverted, all four non-object cases throwInvalidOperationException.LockFanOutTests.RefThatIsNotAnObject_IsRefusedWithoutCallingUpstreamchecks that the endpoint returns 400 and makes no upstream lock call.The full suite passes locally: 361 tests, 0 failed.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Md2Tr7FWcbqPdwq2BjeG79
Generated by Claude Code