fix: redirect debug/status output to stderr for json/xml output formats#573
Merged
buger merged 1 commit intoJun 3, 2026
Merged
Conversation
When MCP tools call probe with --format=json (or xml), debug lines like "Pattern: ...", "Path: ...", and "Falling back to BM25 ranking..." were written to stdout. The JSON parser received these lines before the actual JSON payload and failed with "Unexpected token 'P'...". Changes: - main.rs: guard the Pattern/Path println! blocks behind a format check so they are only printed for text output (not json/xml) - result_ranking.rs: change "Falling back to BM25 ranking..." and related debug println! calls to eprintln! so they go to stderr regardless of output format - ranking.rs: same — SIMD debug messages to eprintln! Fixes #568
Collaborator
|
Yep, makes sense! Thank you! |
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.
Problem
Closes #568.
When probe is called with
--format=json(e.g. via the MCPsymbolstool), debug lines likePattern: ...,Path: ..., andFalling back to BM25 ranking...were written to stdout before the JSON result. Any JSON parser downstream received:And failed with:
Unexpected token 'P', "Pattern: s"... is not valid JSONFix
src/main.rs— wrap thePattern:andPath:println!blocks in a format guard so they are only printed for text output:src/search/result_ranking.rs— change"Falling back to BM25 ranking..."and related debugprintln!calls toeprintln!.src/ranking.rs— same for SIMD debug messages.All status/diagnostic output now goes to stderr, leaving stdout clean JSON for downstream parsers.