Skip to content

Python extraction crashes on over-deep relative import resolving to filesystem root #2605

Closed

Description

@sortakool

Summary

Graphify 0.9.39 crashes during Python AST extraction when a relative import climbs to the filesystem root and the candidate path has no name.

The failure is reproducible from the public Ruff TID252 fixture, which contains a 27-dot relative import.

Reproduction

Environment:

  • graphifyy 0.9.39
  • CPython 3.14.0
  • code-only extraction
  • exact Ruff fixture SHA-256: e660e8da415dca3af859142cde9dab8d13072ff470921c37d1f94695ed5f1193

Command:

graphify extract ruff-exact --code-only --force

Observed result:

AST extraction failed: PosixPath("/") has an empty name

Exit code: 1.

A reduced fixture containing only the same 27-dot import fails identically. Python parses that import with level=27 and module=None.

A nearby level-1 relative-import control succeeds and produces a graph with 4 nodes and 2 edges.

Cause

The Python module resolver reaches Path("/") and calls candidate.with_suffix(".py") without guarding candidate.name. Path("/").with_suffix(".py") raises the observed ValueError.

Expected behavior

An over-deep relative import should be ignored or represented as unresolved without aborting extraction of the entire source tree.

Suggested narrow fix

Before calling with_suffix, return no candidate when candidate.name is empty. This avoids changing Graphify behavior for legitimate named out-of-root relative imports.

Validation requested

  • hostile 27-dot relative-import regression
  • ordinary relative-import passing control
  • existing out-of-root named import tests remain green
  • full Ruff code-only extraction completes and writes a graph

The reproduction ran in a disposable isolated environment with a 60-second wall limit, 30-second CPU limit, 2 GiB process-group RSS limit, and 10 MiB log limit.

Activity

  1. added a commit that references this issue on Aug 11, 2026
  2. safishamsi commented on Aug 11, 2026

    @safishamsi
    Member

    Fixed in v0.9.40 (graphifyy==0.9.40 on PyPI). Resolving an over-deep relative import (from ....x import y above the package root) no longer crashes: an empty-name (filesystem-root) candidate is now guarded, so extraction degrades gracefully instead of raising. Thanks @SinghAman21 (PR #2611).

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