codebase-memory-mcp icon indicating copy to clipboard operation
codebase-memory-mcp copied to clipboard

query_graph: a WHERE comparison between two properties (a.file_path = b.file_path) fails with "expected value at pos N"

Open nefayran opened this issue 1 month ago • 4 comments

Version

Built from source at 83edbd3a (main, 2026-10-10). The 0.9.0 build installed here gives the same error.

Platform

macOS (Apple Silicon)

Install channel

Built from source

Binary variant

standard

What happened, and what did you expect?

A WHERE condition that compares one variable's property with another variable's property does not parse. The query stops with expected value at pos 44, the position of the right-hand operand. The same happens with <> and after WITH a, b WHERE. Comparing a property with a literal works.

The README's "Supported Cypher" section lists = <> < <= > >= under WHERE and says anything outside the subset fails with a clear unsupported … error. I expected either the rows where both ends of the edge are in the same file, or an unsupported error that names property-to-property comparison.

This is the direct way to ask for calls that stay inside one file or cross files (a.file_path <> b.file_path).

Reproduction

mkdir -p /tmp/cbm-where && cd /tmp/cbm-where && git init -q
cat > demo.go <<'EOF'
package demo

func Helper() int { return 1 }

func Caller() int { return Helper() }
EOF
git add -A && git commit -qm init
codebase-memory-mcp cli index_repository --repo-path /tmp/cbm-where --mode full
# --project is the name index_repository printed
codebase-memory-mcp cli query_graph --project <project> --query "MATCH (a)-[:CALLS]->(b) WHERE a.file_path = b.file_path RETURN a.name, b.name LIMIT 20"
WHERE result
a.file_path = b.file_path expected value at pos 44
a.name <> b.name expected value at pos 40
WITH a, b WHERE a.file_path = b.file_path expected value at pos 54
b.file_path = 'demo.go' 1 row: Caller Helper

Confirmations

  • [x] I searched existing issues and this is not a duplicate. #1293 and #2250 are about NOT with patterns and predicates, not about comparing two properties.
  • [x] My reproduction uses shareable code (a dummy snippet or a public OSS repository), not proprietary code.

Written with Claude Code (Claude Opus 5.5).

nefayran avatar Oct 11 '26 12:10 nefayran

Thank you for the compact comparison table and the literal-operand control. The parser error versus the documented supported subset is clear in the report. Both property-to-property support and a precise unsupported diagnostic need verification; there is no confirmed resolution yet.

DeusData avatar Oct 19 '26 22:10 DeusData

Hi! I'd like to work on this one.

I reproduced it on current main. The WHERE parser only accepts a literal after the operator, so b.file_path is rejected. My plan is to accept a var.prop (or a bare WITH alias) on the right side, read it from the same row at evaluation time, and make sure the early WHERE pass waits until both variables are bound. I'll add regression tests for =, <>, numeric comparisons, the WITH a, b WHERE form, and missing properties.

Happy to adjust if you'd prefer a different approach.

harshitaajoshi avatar Oct 21 '26 07:10 harshitaajoshi

Thank you for offering to work on this and spelling out the binding-order and missing-property checks. The proposed property/alias comparison semantics need a maintainer response before we give direction. Sorry for the delay—I’ll follow up soon.

DeusData avatar Oct 25 '26 17:10 DeusData

Fixed on main by #2744 (merge f05c221e9c47). Thank you, @nefayran, for the clear report and the minimal query: a WHERE comparison between two properties, such as a.file_path = b.file_path, now parses and evaluates instead of failing with "expected value at pos N". Thanks also to @harshitaajoshi for the fix. It is included from the next release; if a property-to-property comparison still fails for you there, please reopen with the query.

DeusData avatar Oct 26 '26 00:10 DeusData