You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Treat directory prefixes as literal paths when selecting notes to move #1887
Follow-up from the reviewed CodeRabbit deep scan (K3). This ticket tracks one distinct fix; duplicate scan rows are consolidated here.
Reviewed evidence and scope
K3 (scan ID ec9ff094-17d5-446b-ae55-a9039769f28c, review A, High): Literal directory prefix is interpolated into LIKE; local SQL probe confirms underscore matches a sibling. Directory move trusts these rows and slices by prefix length. Escape wildcards and test percent/underscore folder names.
Source at current baseline: src/basic_memory/repository/entity_repository.py:763.
Fix and validation
Treat directory prefixes as literal paths when selecting notes to move.
Recheck current callers and supported behavior before choosing the smallest complete fix.
Add a bounded regression at the affected public or service boundary; demonstrate it fails without the fix.
Preserve legitimate inputs and tenant/project boundaries. Run focused tests plus repository static/type checks.
The scan/review establishes the code-level concern described above; it does not establish production exploitation. Conditional branches and local/tooling-only exposure must retain that scope.
Component: Database/repository layer (EntityRepository directory prefix lookup), affecting directory move via CLI/MCP. Not Cloud-specific.
Priority: Medium. The LIKE pattern at src/basic_memory/repository/entity_repository.py (~L763, f"{directory_prefix}/%") does not escape % or _, so a folder like my_dir can also match a sibling such as myXdir. Directory move then slices paths by prefix length, which could move or rewrite the wrong notes. The impact is on local file/DB correctness, and the scan does not establish production exploitation.
Complexity: Simple. Escape %, _ and the escape character in the prefix, add escape= to the like() call (or use startswith(..., autoescape=True)), then add regression tests with _ and % folder names on SQLite and Postgres. Check the other callers of this method and keep the project boundary intact.
Duplicates: A quick gh search issues found no obvious duplicate.
Activity
claude commentedon Oct 28, 2026
Claude finished @phernandez's task in 16s —— View job
Triage
bug; existingsecuritylabel preserved.EntityRepositorydirectory prefix lookup), affecting directory move via CLI/MCP. Not Cloud-specific.LIKEpattern atsrc/basic_memory/repository/entity_repository.py(~L763,f"{directory_prefix}/%") does not escape%or_, so a folder likemy_dircan also match a sibling such asmyXdir. Directory move then slices paths by prefix length, which could move or rewrite the wrong notes. The impact is on local file/DB correctness, and the scan does not establish production exploitation.%,_and the escape character in the prefix, addescape=to thelike()call (or usestartswith(..., autoescape=True)), then add regression tests with_and%folder names on SQLite and Postgres. Check the other callers of this method and keep the project boundary intact.gh search issuesfound no obvious duplicate.Triage only; I have not made any code changes.
fix(core): escape literal directory prefixes before moves (#1915)