bazelbuild/bazel · error · ValueError

Path Fragment id not found.

Error message

Path Fragment id not found.

What it means

Thrown by aquery_differ's path_fragment_resolver when walking the parent chain of a path fragment id. Kythe/aquery exec paths are stored as linked fragments; the resolver climbs from the given id through parent_id entries. If any id in the chain is absent from the _id_to_path_fragment table, it raises ValueError('Path Fragment id not found.').

Source

Thrown at tools/aquery_differ/resolvers/path_fragment_resolver.py:39

  def __init__(self, path_fragments):
    self._id_to_path_fragment = {
        path_fragment.id: path_fragment for path_fragment in path_fragments
    }

  def resolve(self, path_fragment_id):
    """Given a path_fragment_id, return the full path.

    Args:
      path_fragment_id: an int id of the path fragment.

    Returns:
      The string representing the full exec path.
    """
    exec_path_tokens = []
    curr_id = path_fragment_id
    while curr_id:
      if curr_id not in self._id_to_path_fragment:
        raise ValueError('Path Fragment id not found.')

      entry = self._id_to_path_fragment[curr_id]
      exec_path_tokens.append(entry.label)
      curr_id = entry.parent_id

    return os.path.join(*reversed(exec_path_tokens))

View on GitHub (pinned to e6e199d060)

Solutions

  1. Re-run both aquery invocations with identical flags (same --output=textproto/--skyframe scope) so their path_fragment sets are consistent.
  2. Ensure the converter feeding _id_to_path_fragment ingests ALL path_fragments from the aquery output, not a filtered subset.
  3. Regenerate the aquery artifacts if the bazel invocation may have been interrupted or the server restarted mid-query.
Defensive patterns

Strategy: validation

Validate before calling

def all_fragments_present(path_fragment_ids, id_to_fragment):
    for pid in path_fragment_ids:
        while pid:
            if pid not in id_to_fragment:
                return False
            pid = id_to_fragment[pid].parent_id
    return True

Try / catch

try:
    path = resolver.resolve(path_fragment_id)
except ValueError as e:
    # 'Path Fragment id not found.' — regenerate aquery artifacts and retry once
    raise

Prevention

When it happens

Trigger: Consuming aquery output where an output/file id references path_fragments that were not included in the converted table — e.g. two aquery invocations with different scopes/flags so one side lacks fragments the other side references, or filtering that dropped path_fragment rows.

Common situations: Diffing aquery results between bazel versions or between queries with different --output options; textproto conversion that skipped some path_fragment entries; truncated aquery output from an interrupted command.

Related errors


AI-assisted analysis of bazelbuild/bazel@e6e199d060 (2026-08-14). Data as JSON: /api/errors/f74e8219f7563567. Report an issue: GitHub.