Repository navigation
Description
Summary
graphify export obsidian and graphify export wiki abort with an unhandled FileNotFoundError on Windows as soon as one node label is long enough to reach the filename cap. The export dies partway through, leaving a half-written vault (some notes present, the rest missing) and a non-zero exit with a raw traceback.
The cap added in #1094 (export._cap_filename, 200 bytes) is sized against the per-component NAME_MAX of 255 bytes. That is the correct constraint on POSIX and the wrong one on Windows, where the limit applies to the whole path: legacy MAX_PATH is 260 characters including the terminating NUL, and HKLM\SYSTEM\CurrentControlSet\Control\FileSystem\LongPathsEnabled is 0 on a default install. So a 200-byte stem under a perfectly ordinary output directory overruns the ceiling before the filesystem's per-component limit is anywhere near.
sanitize_label() caps labels at 256 characters (security._MAX_LABEL_LEN), so labels in this range are expected by design — they come out of the semantic pass over docs/PDFs routinely.
Reproduction
Windows 11, Python 3.12, v8 @ 26128ab, default LongPathsEnabled=0.
The project lives at C:\Users\abhay\AppData\Local\Temp\gx\payments-api (49 chars — shorter than a typical real checkout), and graph.json contains one document node whose label is 207 characters:
> graphify export obsidian .
Traceback (most recent call last):
...
File "C:\graphify\graphify\cli.py", line 2667, in dispatch_command
n = _to_obsidian(G, communities, str(obsidian_dir),
File "C:\graphify\graphify\export.py", line 642, in to_obsidian
if _owned_write(fname, "\n".join(lines)):
File "C:\graphify\graphify\export.py", line 560, in _owned_write
target.write_text(content, encoding="utf-8")
FileNotFoundError: [Errno 2] No such file or directory: 'graphify-out\\obsidian\\Consolidating the payment reconciliation ledger into a single append-only settlement journal so that replayed provider webhooks always keep their original ordering for downstream audit and di_89c6113a.md'
export wiki fails the same way, and sooner — graphify-out\wiki\ is written by wiki._safe_filename, which caps at 200 characters with no hash suffix:
> graphify export wiki .
File "C:\graphify\graphify\wiki.py", line 328, in to_wiki
(out / f"{slug}.md").write_text(article, encoding="utf-8")
FileNotFoundError: [Errno 2] No such file or directory: 'graphify-out\\wiki\\Consolidating_the_payment_reconciliation_ledger_into_a_single_append-only_settlement_journal_so_that_replayed_provider_webhooks_always_keep_their_original_ordering_for_downstream_audit_and_dispute_res.md'
This also reproduces without any corpus at all — three of the repo's own regression tests fail on Windows for exactly this reason on a clean v8 checkout:
> uv run --frozen pytest tests/test_obsidian_filename_cap.py -q
FAILED tests/test_obsidian_filename_cap.py::test_obsidian_long_ascii_label_does_not_crash
FAILED tests/test_obsidian_filename_cap.py::test_obsidian_distinct_long_labels_sharing_prefix_do_not_collide
FAILED tests/test_obsidian_filename_cap.py::test_obsidian_wikilink_resolves_after_truncation
3 failed, 2 passed
Root cause
export._cap_filename(s, limit=200) and wiki._safe_filename(name) both treat 200 as a constant. Neither knows where the file is about to be written, so the destination directory contributes an unbounded amount to a bounded budget:
len("C:\\Users\\me\\projects\\payments-api\\graphify-out\\obsidian") # 55
+ len("\\") # 1
+ 200 # stem
+ len("_1") # dedup suffix
+ len(".md") # 3
= 261 > 259 usable MAX_PATH characters
The graphify-out\obsidian / graphify-out\wiki suffix alone is 21/17 characters, so the headroom left for the user's own checkout path is about 34 characters. C:\Users\<name>\Documents\<repo> exhausts that on its own.
export wiki is the more damaging of the two: AGENTS.md tells assistants to navigate graphify-out/wiki/index.md in preference to raw files, so on Windows that entry point simply never gets written for any graph containing one long label.
Why the open issues don't already cover this
- _cap_filename's hardcoded limit=200 assumes NAME_MAX=255; breaks on eCryptfs (real limit can be ~143 bytes) #2109 / PR fix: honor target filesystem filename limits #2118 — a per-component
NAME_MAXbelow 255 (eCryptfs). The fix queriesPC_NAME_MAXthroughos.pathconf, which does not exist on Windows, and states that it "preserves the existing 200-byte behavior on conventional filesystems". Windows stays broken either way; the two fixes are complementary and touch different numbers. - PR fix(windows): preserve deep local and UNC files across the corpus pipeline #2317 — deep paths on the input side (corpus discovery and reading). It does not touch
export.pyorwiki.py. - [Windows] Long paths (>260 chars) never hashed by save_manifest/_md5_file — files re-flagged as changed on every update #1655 — long-path hashing in
save_manifest/_md5_file, also input-side.
Suggested fix
Derive the stem cap from the destination directory instead of hardcoding it, and reserve room for the pieces callers append after the cap (_COMMUNITY_ prefix, _1/_2 collision suffixes, .md). POSIX keeps returning 200 unchanged, so existing vaults stay byte-for-byte stable and #2109's separate NAME_MAX question is untouched.
Capping is preferable to writing through \\?\ extended-length paths here: the output is meant to be opened by Obsidian, Explorer and other editors, and handing those a 300-character path just moves the failure downstream to the tools the user actually opens the vault with.
I have this working locally with regression coverage and will open a PR against v8 shortly.
Environment
| OS | Windows 11 Home Single Language 26200, LongPathsEnabled=0 (default) |
| Python | 3.12 (and 3.10) |
| graphify | v8 @ 26128ab (0.9.40) |
Activity
abhay-codes07 commentedon Aug 11, 2026
Opened #2656 with the fix and regression coverage.
fix(export): budget export filenames against the destination path, no…
harden(export): widen dedup reserve to 5 and add multibyte budget test (
chore: bump to 0.9.43
chore: bump to 0.9.44
safishamsi commentedon Aug 15, 2026
Fixed in v0.9.44 (on PyPI now) via #2656, thanks @abhay-codes07. Closing.
fix(export): honor the target filesystem's NAME_MAX in export filenames
fix(export): honor the target filesystem's NAME_MAX in export filenames