fix(mcp): preserve coverage scope labels#1148
Open
aaiyer wants to merge 1 commit into
Open
Conversation
Signed-off-by: Anand Aiyer <anand@aiyer.com>
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.
What does this PR do?
check_index_coveragestored each normalized scope with yyjson's non-copyingstring API even though the source was a loop-local buffer. With multiple
scopes, later iterations could overwrite earlier labels; AddressSanitizer also
reported a stack-use-after-scope when the response was serialized.
Use
yyjson_mut_obj_add_strcpyso the mutable document owns each scope label.Add a regression that requests three distinct, equal-length scopes and asserts
that every returned label and its order are preserved.
This PR is intentionally limited to one issue and two files:
src/mcp/mcp.ctests/test_mcp.cIt does not change coverage semantics, tool inputs, schemas, pagination, or
status handling.
Verification
stack-use-after-scopeinhandle_check_index_coverageduring yyjsonserialization.
make -j4 -f Makefile.cbm test-focused TEST_SUITES=mcp: 166/166 passed.scripts/lint.sh --ciwith CI's clang-format 20.1.8 and cppcheck 2.20.0:passed.
make -j"$(nproc)" -f Makefile.cbm security: all seven security layerspassed, including MCP robustness 23/23.
The broad
scripts/test.shrun reached the end with all test cases reportingPASS, then LeakSanitizer exited nonzero for a 4,976-byte allocation originatingfrom the unchanged
cli_install_plan_receipt_no_mutation_issue388test path(
tests/test_cli.c:2398/src/cli/cli.c:7539). This PR does not touch thatpath; it is being kept out of this one-issue change and investigated separately.
Checklist
git commit -s) — required, CI rejectsunsigned commits (DCO, see CONTRIBUTING.md)
make -f Makefile.cbm test) — all cases passed, butthe separate unchanged CLI LeakSanitizer finding above made the process
exit nonzero
make -f Makefile.cbm lint-ci)