search_code (and detect_changes): rejects projects indexed by index_repository when root_path contains '$'

Aperta
#3,151 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
70/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
c, linux
Ambito
backend, cli

Direzione di ricerca

Start with validate_search_path_arg and validate_search_args at the cited locations in src/mcp/mcp.c, then inspect the detect_changes validation around lines 20275–20287. Trace how root_path reaches these checks and how paths are passed to search. Reproduce using a repository path containing $; done means search_code finds the match and detect_changes accepts the indexed path, or indexing clearly rejects it upfront.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug ux/behavior
Version

codebase-memory-mcp 0.12.1 (built from source at 9a4da7a3; also verified unchanged on main d5e39e5a, src/mcp/mcp.c:17466-17514, 18244, 20275-20287)

Platform

Linux (x64)

Install channel

Built from source

Binary variant

standard

What happened, and what did you expect?

index_repository succeeds on a valid repository path containing $ (e.g., /tmp/repo$cash), persists its root_path, and list_projects returns the indexed project normally.

However, calling search_code on that indexed project with only {"project": "dollar_repo", "pattern": "hello"} (without passing file_pattern or path_filter) immediately fails with:

path or file_pattern contains invalid characters

Root cause: validate_search_args(root_path, file_pattern) (src/mcp/mcp.c:17506-17514) runs validate_search_path_arg (mcp.c:17466-17481) on the persisted root_path, which still rejects $ (as well as ;, |, ", etc., whereas #272 relaxed & because POSIX single-quoting neutralizes shell metacharacters). The same check also rejects root_path in detect_changes (mcp.c:20275-20287).

Expected: either search_code / detect_changes safely handle valid POSIX/Windows paths containing $ (since POSIX single-quoting already neutralizes $, or by avoiding shell interpolation via argv), or index_repository rejects/warns upfront instead of indexing a project whose search_code calls always fail with a misleading "path or file_pattern contains invalid characters" message even when the caller passed neither path nor file_pattern.

Reproduction
  1. Code: create a minimal dummy repo in a directory whose name contains $:
    mkdir -p '/tmp/repo$cash'
    printf 'def hello():\n    return "hello"\n' > '/tmp/repo$cash/main.py'
    
  2. MCP calls:
    • Step 1 — index_repository:
      {"repo_path": "/tmp/repo$cash", "name": "dollar_repo", "mode": "fast"}
      
      Output: succeeds ("project": "dollar_repo", "files_indexed": 1, "nodes": ...).
    • Step 2 — list_projects:
      {"format": "json"}
      
      Output: lists "name": "dollar_repo", "root_path": "/tmp/repo$cash".
    • Step 3 — search_code (no file_pattern passed):
      {"project": "dollar_repo", "pattern": "hello"}
      
      Actual output (isError: true):
      path or file_pattern contains invalid characters
      
  3. Expected for Step 3: search_code returns the match in main.py (or, if $ paths are intentionally unsupported, index_repository rejects them at index time and the error clearly names the project root_path rather than "path or file_pattern").
Logs
Step 1 (index_repository): {"project":"dollar_repo",...,"files_indexed":4,"nodes":18,"edges":19,...}
Step 2 (list_projects): {"projects":[{"name":"dollar_repo","root_path":".../repo$cash"}],"total":1,...}
Step 3 (search_code, isError=true): path or file_pattern contains invalid characters
Confirmations
  • I searched existing issues and this is not a duplicate.
  • My reproduction uses shareable code (a dummy snippet or a public OSS repository), not proprietary code.
Lingua principale
C
Stelle
45.8k
Fork
3.8k
Merge medio
2g 18h
PR unite (30g)
108

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di DeusData/codebase-memory-mcp

Tutte le issue di DeusData/codebase-memory-mcp

Issue simili

Altre issue su C

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.