Skip to content

test(mcp): regression guard for relative repo_path canonicalization (#794)#987

Merged
DeusData merged 2 commits into
mainfrom
fix/relative-repopath-guard
Jul 9, 2026
Merged

test(mcp): regression guard for relative repo_path canonicalization (#794)#987
DeusData merged 2 commits into
mainfrom
fix/relative-repopath-guard

Conversation

@DeusData

@DeusData DeusData commented Jul 9, 2026

Copy link
Copy Markdown
Owner

Summary

Verification of #794 (relative repo_path "." corrupts + auto-deletes the project DB on every run, v0.8.1) against current main: already fixed — the path is canonicalized before anything derives from it. Reproduced the reporter's exact flow (cd repo && cli index_repository '{"repo_path": "."}'): project name is path-derived (not "root"), the projects table stores the absolute canonical root_path, the DB persists, and queries work.

This PR lands the regression guard: index "." from inside the repo, assert the three things the old failure mode broke (path-derived name, absolute stored root_path == realpath, surviving + queryable DB). If the canonicalization ever regresses, the guard fails at the auto-clean step (missing DB) or the root_path assertion.

Net diff: tests only, +100 lines.

Closes #794

@DeusData DeusData added this to the 0.9.1-rc milestone Jul 9, 2026
DeusData added 2 commits July 9, 2026 22:37
On v0.8.1, index_repository with repo_path "." flowed the literal dot
through everything derived from the path: the project was named
"root", the projects table stored root_path="." verbatim, the
post-dump integrity check flagged bad_root_path and auto-deleted the
entire DB — while the response still reported status "indexed" with
full node counts. Verified fixed on current main (the path is
canonicalized before derivation: correct project name, absolute
root_path, persistent and queryable DB).

The guard indexes with repo_path "." from inside the repo and asserts
the three things the old failure mode broke: path-derived project name
(never "root"), absolute canonical root_path in the projects table,
and a DB that survives the run and answers queries.

Closes #794

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
glibc _FORTIFY_SOURCE aborts realpath() into a sub-PATH_MAX buffer
regardless of the actual path length, and Windows has no realpath at
all. Size the buffers at PATH_MAX and skip the guard on Windows (the
#794 canonicalization logic is platform-independent; the four Unix
legs carry it).

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
@DeusData DeusData merged commit 22a8ff1 into main Jul 9, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

index_repository with relative repo_path (".") corrupts and auto-deletes the project DB every run

1 participant