Repository navigation
fix: redact the code search query before it leaves the machine - #295
Merged
PierrunoYT merged 1 commit intoOct 15, 2026
Merged
Conversation
The search_code query went to OpenRouter for embedding and reranking unmasked, while the candidate chunks already went through redactSecrets. A token the model copied into its own query therefore reached a third-party service (PierrunoYT#286).
PierrunoYT
approved these changes
Oct 15, 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.
search_codesent the model's query to OpenRouter unmasked, both for the embedding (embed([query], 'query')) and for the rerank, while the candidate chunks were already run throughredactSecrets. A token the model had copied into its own query therefore reached a third-party service — the same holeweb_searchclosed in #73, and reachable in Ask mode becausesearch_codeis a read-only tool that subagents may call too.The fix is the one the issue suggests: redact once before both calls (
const sent = redactSecrets(query)), the wayweb.ts:168-169does for its query.Closes #286.
Verification
src/main/search/code_index.test.ts(masks secrets in the query before it leaves to the embedding and the reranker (#286)) asserts the fake embedder's'query'call andreranker.seen.queryboth carryfix the login that stores [REDACTED:_____].git show HEAD:src/main/search/code_index.ts) shows the rawghp_…token reaching both the embedder and the reranker, so the test does pin the behaviour rather than passing vacuously.npx vitest run --project unit src/main/search/code_index.test.ts→ 29 passed.npx tsc --noEmit -p tsconfig.node.json,npx eslinton both files andnpx prettier --checkon both files → clean.npx vitest run --project unit: 1633 passed, 5 test files failed —apply_patch,edit_backups,file_operations,shellandtools, every one of them withThe native file helper was not found. Build it with npm run build:sandbox.That helper needs a C compiler, which this machine has not, sonpm run test:unitcould not be used as-is; none of those five files importcode_index/CodeIndex/search_code(checked by grep), so nothing there is affected by this change.