fix(mcp): skip direct store open for invalid project names - #1442
fix(mcp): skip direct store open for invalid project names#1442dergachoff wants to merge 1 commit into
Conversation
project_db_path() returns an empty path for invalid project names, and SQLite opens "" as an anonymous temporary database. The temp db fails the integrity check, so resolve_store_internal() quarantined it as a relative ".corrupt.<hex>" file in the process cwd — silent litter in whatever directory the server was started from, on every query, while the caller only saw an ordinary not-found error. Skip the direct open when the path is empty and fall through to the 704 fallback scan (which matches by internal name, so a genuine typo stays not-found), and refuse an empty path in quarantine_corrupt_store() as a second line of defense. Fixes DeusData#1425 Signed-off-by: Ivan Dergachev <dergachoff@gmail.com>
|
Thanks for opening this — it has been seen, and it is queued. This note is automated, but it is not a brush-off: it exists so you know where your PR stands instead of having to guess from silence. Current review status: working through a backlog. What that means for this PR, concretely:
Things that will genuinely speed it up whenever review does happen:
If this fixes a bug, a reproduction we can run is worth more than a description of the symptom. Thanks for contributing, and sorry in advance for the wait. |
|
Duplicate of #1437 (same guards, same test) — closing in favor of the maintainer's version. Happy to port anything if it turns out mine covered a case yours doesn't. |
Problem
A query with an invalid project name (
bad name,#upstream) makes the server write a.corrupt.<hex>file into the process's cwd — for the daemon, whatever repo it was started in. One 4096-byte file per query, invisible to the caller, who just gets "project not found". Fixes #1425.Root cause
project_db_path()returns""on validation failure.resolve_store_internal()passed it tocbm_store_open_path_query(""), which SQLite opens as an anonymous temporary database. The temp db fails the integrity check (noprojectstable), so the recovery path "quarantined" it:"%s.corrupt.%016llx"of an empty prefix is a relative path, created in cwd.Fix
resolve_store_internal(): skip the direct open when the path is empty, fall through to the query_graph / search_graph return "project not found" inconsistently; DBs valid on disk but CLI looks up wrong inode #704 internal-name fallback scan. A typo still returns not-found; a legacy db with an invalid internal name can still resolve.quarantine_corrupt_store(): refuse an empty path (defense in depth; unreachable via the resolver now).No behavior change for valid names: validation passing always yields a non-empty
cache_dir/<project>.dbpath.Validation
tool_query_invalid_project_name_no_corrupt_litter: query withproject:"bad name"from a scratch cwd asserts the not-found reply, zero recovery-lease acquisitions, and zero.corruptentries in cwd and cache dir.path=signature); green with both.mcp+mcp_mutation_guard: 214 passed, 2 skipped.