Skip to content

fix(mcp): refuse create_memory_project path mismatch - #1840

Closed
MbappeWU wants to merge 2 commits into
basicmachines-co:mainfrom
MbappeWU:fix/create-project-path-mismatch-1811
Closed

MbappeWU wants to merge 2 commits into
basicmachines-co:mainfrom
MbappeWU:fix/create-project-path-mismatch-1811

Conversation

@MbappeWU

Copy link
Copy Markdown
Contributor

Problem

create_memory_project treated any existing project name as an idempotent success. When the caller passed the same name with a different path, the tool returned ✓ Project already exists, re-indexed the stored project, and silently ignored the requested path (#1811).

Approach

Mirror the path check already used by API add_project:

  • Normalize both paths with os.path.abspath(os.path.expanduser(...)).
  • Same directory → keep the existing idempotent re-index success (already_exists=True).
  • Different directory → fail fast without indexing; name both paths in text (# Error) and JSON (error: PATH_MISMATCH, already_exists: false).

Also update the man page and the integration cases that previously encoded the buggy success path.

Verification

  • Failing-before: new mismatch unit tests failed with the old success payload.
  • Passing-after: uv run pytest for the new unit tests, the partial-create retry test, test_create_project_duplicate_name, and test_create_memory_project_json_output_is_idempotent → 6 passed.
  • Full tests/mcp/test_tool_project_management.py reported 43 passed during local development.
  • ruff check / ruff format / ty check on touched Python files clean. Repo-wide just fast-check still hits pre-existing unresolved pymilvus imports unrelated to this change.

Fixes #1811

Add regression coverage for basicmachines-co#1811: same name with a different path
must fail, while the same directory stays idempotent. Update the
manual page and integration cases that previously encoded the bug.

Signed-off-by: MbappeWU <MbappeWU@users.noreply.github.com>
When create_memory_project finds an existing name, compare normalized
paths the same way the API add_project path does. Equal paths keep the
idempotent re-index success. Different paths fail fast with both paths
named and without re-indexing.

Fixes basicmachines-co#1811

Signed-off-by: MbappeWU <MbappeWU@users.noreply.github.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-23T13:38:11.438563Z
We couldn’t complete this review. Comment @codex review to try again.
08cce85 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@MbappeWU

Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

@MbappeWU

Copy link
Copy Markdown
Contributor Author

@CLAassistant check

@phernandez

Copy link
Copy Markdown
Member

Thanks @MbappeWU — fork PRs don't run our test suite, so I've moved this to an in-repo branch in #1846 with your two commits kept as authored. I added one commit on top: the mismatch is raised as an ALREADY_EXISTS refusal (the tool's other refusals are tool errors), and the check is skipped for cloud routing, where project paths are tenant-relative and derived from the name. Closing this in favor of #1846; your commits will land with your authorship.

@phernandez phernandez closed this Oct 23, 2026
@MbappeWU

Copy link
Copy Markdown
Contributor Author

Thanks @phernandez — appreciated you carrying the commits into #1846 and for the extra mismatch-as-error follow-up. Happy to help if anything else is needed on that branch.

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.

create_memory_project reports success for an existing name with a different path

2 participants