Skip to content

fix(trace-path): use portable case-insensitive symbol lookup - #127

Merged
spelech merged 2 commits into
mainfrom
fix/trace-path-postgres-nocase
Nov 12, 2026
Merged

spelech merged 2 commits into
mainfrom
fix/trace-path-postgres-nocase

Conversation

@spelech

@spelech spelech commented Nov 12, 2026

Copy link
Copy Markdown
Owner

Problem

On PostgreSQL (the portable bundle), trace_path fails for every symbol that is not an exact match:

Error executing trace_path: (psycopg.errors.UndefinedObject) collation "nocase" for encoding "UTF8" does not exist
LINE 1: ...line, signature FROM ast_symbols WHERE (name = $1 COLLATE NO...

The two fallback queries in graph_traversal.py (symbol lookup and relationship lookup) use COLLATE NOCASE, which only SQLite has. So a wrong letter case, or a name that is not indexed, gives a database error instead of a result or a "not found" answer.

Fix

Both fallback queries now use LOWER(column) = LOWER(?) (and LOWER(full_symbol) LIKE LOWER(?)), which works on SQLite and PostgreSQL. I ran the new symbol query on a PostgreSQL 16 index: assistantscontroller.runinstance finds AssistantsController.RunInstance.

Tests

tests/test_trace_path_case_insensitive.py:

  • A lowercase symbol resolves to the indexed symbol and its callers.
  • graph_traversal.py contains no NOCASE (CI has no PostgreSQL, so this guard keeps the SQL portable).

🤖 Generated with Claude Code

Steve Pelech and others added 2 commits November 12, 2026 13:54
When trace_path found no exact symbol, its fallback queries used
`COLLATE NOCASE`, which only SQLite has. On PostgreSQL the tool failed with
"collation nocase for encoding UTF8 does not exist" for any symbol that was
not an exact match (for example a wrong letter case or an unknown name).

The fallback now compares LOWER(column) = LOWER(?), which works on both
databases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@spelech
spelech merged commit f64252e into main Nov 12, 2026
15 checks passed
@spelech
spelech deleted the fix/trace-path-postgres-nocase branch November 12, 2026 20:06
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.

1 participant