Skip to content

fix: catch OSError when Cargo.toml is missing during --cargo introspection#1428

Closed
DhruvTilva wants to merge 1 commit into
Graphify-Labs:v8from
DhruvTilva:fix/cargo-missing-file-traceback
Closed

fix: catch OSError when Cargo.toml is missing during --cargo introspection#1428
DhruvTilva wants to merge 1 commit into
Graphify-Labs:v8from
DhruvTilva:fix/cargo-missing-file-traceback

Conversation

@DhruvTilva

@DhruvTilva DhruvTilva commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Small, isolated fix: catches a missing-file error that currently crashes --cargo with a raw traceback instead of a clean message. One-line change, no new behavior, no risk to existing functionality.

Before: --cargo on a missing Cargo.toml crashes with a raw 10-line Python traceback — confusing for anyone who just typo'd a path.

After: Same situation now exits with one clean line: error: [Errno 2] No such file or directory: '...\Cargo.toml' — and exit code 1, so scripts/CI calling this still detect failure correctly.

Problem

graphify extract <path> --cargo against a folder with no Cargo.toml throws a raw, unhandled FileNotFoundError straight at the user:
FileNotFoundError: [Errno 2] No such file or directory: 'C:\path\Cargo.toml'
A typo'd path or running --cargo one directory too high gets you a 10-line traceback instead of a sentence telling you what went wrong.

Root cause

introspect_cargo() opens Cargo.toml directly, so a missing file raises FileNotFoundError — a subclass of OSError. The call site in __main__.py only catches ConnectionError and ImportError, so this one slips through uncaught.

Testing

  • Missing Cargo.tomlerror: [Errno 2] No such file or directory: '...\Cargo.toml', exit code 1, no traceback
  • Valid Cargo.toml → introspection still runs and extracts crate nodes exactly as before
  • pytest, ruff check, pyright all green on the changed file

@safishamsi

Copy link
Copy Markdown
Collaborator

Merged into v8 as aa06e10 (cherry-picked onto current v8). Full suite green on 3.10 + 3.12. Thanks @DhruvTilva!

@safishamsi safishamsi closed this Jun 22, 2026
@DhruvTilva

Copy link
Copy Markdown
Contributor Author

Merged into v8 as aa06e10 (cherry-picked onto current v8). Full suite green on 3.10 + 3.12. Thanks @DhruvTilva!

Great @safishamsi
Glad it helps :)

safishamsi added a commit that referenced this pull request Jun 23, 2026
Query perf, a skill graph-health gate, and a batch of install/extraction fixes:
- #1431 trigram query prefilter (faster, results unchanged)
- #1437 Step 4.5 graph-health gate + semantic-cache anchored on the scan root
- #1411 CUDA (.cu/.cuh) via the C++ extractor
- #1402 cross-file type-annotation refs no longer duplicate nodes
- #1403 hermes install -> %LOCALAPPDATA% on Windows
- #1409 no punctuation-only Obsidian/Canvas filenames
- #1413 opencode reminder backtick command-substitution fix
- #1428 graphify extract --cargo handles missing Cargo.toml
- #1429 prs.py F821 cleanup

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

2 participants