fix(mcp): stop quarantining an anonymous temp db on invalid project names (#1425) - #1437
Merged
Merged
Conversation
…ames (#1425) A project name failing cbm_validate_project_name made project_db_path() return an empty path, which cbm_store_open_path_query passed to SQLite - and SQLite opens "" as an anonymous temp database. The healthy temp db then failed the integrity check (no projects table) and quarantine_corrupt_store rendered ".corrupt.<hex>" from the empty prefix: a RELATIVE path, dropped as a 4 KB file into whatever directory the daemon was started from, on every such query. The caller only ever saw a clean 'project not found', so nothing pointed at the litter. Two guards, per the reporter's analysis: resolve_store_internal skips the direct open on an empty path and falls through to the existing fallback scan (which can still resolve legacy dbs whose internal name predates validation), and quarantine_corrupt_store refuses an empty path outright (belt-and-braces - nothing at such a path is worth quarantining). Regression test: tools/call search_graph with project "bad name" from a temp cwd asserts the clean not-found error AND that no .corrupt.* file appears in the cwd. RED before (litter created), GREEN after, RED again on revert. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.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.
Fixes #1425.
Root cause (exactly as @dergachoff diagnosed)
project_db_path()yields""for names failing validation → SQLite opens""as an anonymous temp db → integrity check fails (noprojectstable) →quarantine_corrupt_storerenders"%s.corrupt.%016llx"with the empty prefix → a relative.corrupt.<hex>file lands in the daemon's cwd on every such query, while the caller sees a clean "project not found".Fix
Two guards, following the reporter's proposed design:
resolve_store_internalskips the direct open when the path is empty and falls through to the existing fallback scan — which as a bonus can still resolve legacy dbs whose internal name predates validation.quarantine_corrupt_storerefuses an empty path outright (belt-and-braces; logsempty store pathinstead of quarantining nothing).Verification
tools/call search_graphwith"project":"bad name"from a temp cwd asserts the clean not-found error and zero.corrupt.*files in the cwd. RED on main (litter created), GREEN with the fix, RED again on revert.mcp+mcp_mutation_guard: 214 passed / 2 skipped (pre-existing).lint-ciclean.