Skip to content

[Bug]: path answers a file::symbol endpoint from a same-name symbol in another file when the file holds no such symbol (exit 0, warning only) #4264

Closed

Description

@antbald

What happened?

graphify path accepts a file::symbol endpoint whose file holds no such symbol and answers from a same-name symbol in another file. The route is printed on stdout, the only signal is a score warning on stderr, and the exit code is 0. explain handles the same qualifier correctly ("No node matching …").

A qualifier is the caller's way of saying "this file, not the others"; falling back to a score over the bare name returns a route from a module the caller explicitly excluded. The printed route carries labels only (no file, no node id), so it looks exactly like a correct answer. An agent that ignores stderr, or a wrapper that keeps stdout only, reads it as a confirmed call chain. On a real project (34k nodes, about two labels in three shared — every Next.js route.ts exports the same handful of names) this is the common case, not a corner.

Steps to reproduce

Five files, no LLM:

src/billing/route.ts   import { chargeCard } from './charge';
                       export function readRoute(id: string) { return chargeCard(id); }
src/billing/charge.ts  export function chargeCard(id: string) { return `charged:${id}`; }
src/seats/route.ts     import { SeatInput } from './schema';
                       export function readRoute(id: string) { return SeatInput.parse(id); }
                       export function buildManifest() { return SeatInput; }
src/seats/schema.ts    export const SeatInput = { parse: (x: string) => x };
src/admin/route.ts     export function listAdmins() { return []; }
graphify update .          # 11 nodes, 11 edges
graphify path "src/admin/route.ts::readRoute" "chargeCard"

src/admin/route.ts defines no readRoute.

Error output or graph output

$ graphify path "readRoute" "chargeCard"
Ambiguous: 'readRoute' matches 2 nodes in different files.        # correct: refused, exit 1
  src/seats/route.ts
    id: src_seats_route_readroute
  src/billing/route.ts
    id: src_billing_route_readroute
Retry with path::symbol using one of the paths above (e.g. <path>::readRoute()) or the full node id.

$ graphify path "src/admin/route.ts::readRoute" "chargeCard"
Shortest path (1 hops):
  readRoute() --calls [EXTRACTED]--> chargeCard()
warning: source match was ambiguous (top score 249.797, runner-up 249.797)     # stderr
exit=0

$ graphify explain "src/admin/route.ts::readRoute"
No node matching 'src/admin/route.ts::readRoute' found.            # correct

Expected behavior

path with a qualifier that matches no node behaves like explain: it reports that src/admin/route.ts holds no readRoute (ideally listing the files that do) and exits non-zero.

Two small additions would make every answer checkable:

  1. print the node id (or file:line) next to each label in the path output;
  2. exit non-zero whenever the "match was ambiguous" warning fires on an explicitly qualified endpoint.

Graphify version

0.9.82 (PyPI graphifyy). Same behaviour on 0.9.77.

Operating System

Linux (Ubuntu)

Python Version

3.14.4

Installation Method

pip install graphifyy==0.9.82 in a fresh venv (0.9.77 via pipx)

Additional Environment Details

Related, not duplicates: #1969 (explain resolves ambiguous terms silently), #3917 (MCP: silent wrong matches on ambiguous names), #3485 (closed; explain ambiguity message).

Activity

  1. github-actions commented on Oct 9, 2026

    @github-actions

    Thanks for opening this issue, @antbald. A maintainer will take a look soon.

    If you would like to discuss it in real time, come say hi on our Discord server. For longer-form questions and ideas there is also GitHub Discussions.

    To help us triage, please make sure the report includes what you expected, what actually happened, and the steps (and a small sample) to reproduce it.

  2. safishamsi commented on Oct 10, 2026

    @safishamsi
    Member

    Fixed in 0.9.84 (now on PyPI). graphify path and the MCP shortest_path tool now fail closed on a file::symbol endpoint whose file defines no such symbol, instead of falling back to the bare name and answering from a same-named symbol in another file. The refusal lists the files that do define the symbol. Thanks, @antbald.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions