Conversation
guardJsoncComments and readOrCreateJSON each did their own independent s.read(cfgPath), so a file that was comment-free when the guard read it but gained comments before the parse's later read would pass the guard on stale bytes and get silently rewritten as plain JSON, stripping the comments the guard exists to protect (#922). disconnectJSON had the identical shape. Fold the check into a pure guardJsoncCommentsBytes(cfgPath, raw) run against bytes the caller already read, so the guard and the parse/write now always see the same snapshot. The old read-it-yourself guardJsoncComments is kept only for the read-only preview path, which never writes. Flagged as a pre-existing, out-of-scope finding in cross-model review of PR #1340. Verified with call-counting regression tests (fail against the pre-fix code, pass against the fix) and two rounds of independent cross-model review (codex gpt-5.6-sol, then zcode/GLM), the second of which caught a suffix-check-ordering regression and a test coverage gap in the first fix, both corrected here. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Deploying mcpproxy-docs with
|
| Latest commit: |
f21ae3d
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://3c731a78.mcpproxy-docs.pages.dev |
| Branch Preview URL: | https://claude-busy-northcutt-92e1b1.mcpproxy-docs.pages.dev |
Contributor
📦 Build ArtifactsWorkflow Run: View Run Available Artifacts
How to DownloadOption 1: GitHub Web UI (easiest)
Option 2: GitHub CLI gh run download 35814215901 --repo smart-mcp-proxy/mcpproxy-go
|
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This branch has not been deployed
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
guardJsoncCommentsandreadOrCreateJSONeach performed their own independents.read(cfgPath). A file that was comment-free when the guard read it but gained comments before the parse's later read would pass the guard on stale bytes and get silently rewritten as plain JSON — stripping the comments the guard exists to protect (connect opencode fails: OpenCode bootstraps opencode.jsonc, mcpproxy only recognizes opencode.json #922).disconnectJSONhad the identical shape (not previously reported).guardJsoncCommentsBytes(cfgPath, raw []byte)run against bytes the caller already read, so the guard and the parse/write always see the same snapshot. The old, self-readingguardJsoncCommentsis kept only for the read-only preview path, which never writes and so has nothing to race.Test plan
internal/connect/opencode_jsonc_test.goprove the fix via read-call counting (TestConnectJSON_CommentGuardSharesOneReadWithParse,TestDisconnectJSON_CommentGuardSharesOneRead) — each verified locally to fail against the pre-fix code and pass against the fix.TestGuardJsoncComments_SkipsReadForNonJsoncPathguards a suffix-check-ordering regression caught in second-round review.TestConnect_OpenCode_AllowsTrailingCommaJSON,TestPreview_ConnectRefusal_CommentedJsonc,TestPreview_ConnectRefusal_CommentFreeJsoncIsConnectablestill pass.go build(personal + server edition),go vet,gofmt,go test -race ./internal/connect/....golangci-lint(bare and--build-tags server) clean.gpt-5.6-sol(round 1, clean), then zcode/GLM (round 2, caught a suffix-check-ordering regression and a test coverage gap in round 1's fix — both corrected here and re-verified).🤖 Generated with Claude Code