Skip to content

v0.8.43 regression: FileSlice crashes semantic extraction for oversized Markdown #1397

Description

@fibo-blip

Summary

graphify 0.8.43 regresses semantic extraction for oversized Markdown/text files that are expanded into FileSlice units. The string-path coercion added for #1386 now runs inside extract_files_direct() and attempts Path(FileSlice(...)), which crashes before any backend call is made.

This breaks normal graphify extract . --backend <backend> --out . when the changed semantic/doc corpus includes large Markdown files.

This looks related to the interaction between:

Environment

  • graphify: 0.8.43
  • install: uv tool upgrade graphifyy
  • OS: WSL2 Ubuntu
  • backend: observed with --backend deepseek; the minimal repro also shows the failure happens before any backend request, so this is not DeepSeek-specific

Minimal reproduction without making an API call

from pathlib import Path
from tempfile import TemporaryDirectory

from graphify.file_slice import expand_oversized_files
from graphify.llm import extract_files_direct

with TemporaryDirectory() as d:
    root = Path(d)
    doc = root / "large.md"
    doc.write_text("# Large doc\n\n" + ("body text\n" * 5000), encoding="utf-8")

    units = expand_oversized_files([doc], 20_000)
    print([type(u).__name__ for u in units])  # includes FileSlice

    # api_key is dummy; the failure happens before any backend request.
    extract_files_direct(units, backend="deepseek", api_key="dummy", root=root)

Actual behavior

TypeError: argument should be a str or an os.PathLike object where __fspath__ returns a str, not 'FileSlice'

In the CLI path this is surfaced as:

[graphify extract] semantic extraction on 2 files via <backend>...
[graphify] chunk 1/1 failed: argument should be a str or an os.PathLike object where __fspath__ returns a str, not 'FileSlice'
[graphify] WARNING: 1/1 semantic chunk(s) failed — see errors above. Partial results returned.
[graphify extract] error: all semantic chunks failed for backend '<backend>' (2 uncached files)

Expected behavior

extract_corpus_parallel() may coerce user-supplied str | Path inputs before slicing, but after expand_oversized_files() the internal units are Path | FileSlice. extract_files_direct() should preserve FileSlice units and use existing helpers such as unit_path() / _partition_semantic_files() / _read_files() instead of coercing every unit through Path(...).

Suspected root cause

In the v0.8.43 installed package, graphify/llm.py contains:

def extract_files_direct(...):
    ...
    files = [Path(f) for f in files]

That line is safe for str/Path inputs, but unsafe for FileSlice units produced by the slicer. The PR #1389 head appears to remove this coercion from extract_files_direct() and type it as Sequence[Path | FileSlice], which matches the needed behavior. A patch release with that fix would unblock large-doc semantic extraction.

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