You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
export obsidian: OSError ENAMETOOLONG on long node labels (to_obsidian lacks filename length cap that wiki.py has) #1094
graphify export obsidian crashes with OSError: [Errno 63] File name too long when any node has a long label/identifier (~255+ bytes). Reproduced on v0.8.26 (latest) and v0.8.14.
Root cause
In graphify/export.py, to_obsidian writes each note with:
fname=node_filename[node_id] +".md"
(out/fname).write_text("\n".join(lines), encoding="utf-8") # export.py:927 in v0.8.26
node_filename[node_id] is derived from the node label without any length cap. When a node label is a long identifier (e.g. a generated symbol name, or a label sourced from a long string), fname exceeds the filesystem's 255-byte limit and write_text raises OSError [Errno 63].
By contrast, the wiki exporter already guards against this: graphify/wiki.py has _safe_filename(name) which returns s[:200] (caps length at 200 chars, see wiki.py:23). to_obsidian does not reuse this sanitizer.
Reproduce
Create a source file containing a symbol with a ~300-char name (e.g. a very long function/class identifier).
graphify update <dir>
graphify export obsidian <out>
Crash: OSError: [Errno 63] File name too long: '.../<300-char-name>().md'
Suggested fix
Reuse wiki.py's _safe_filename (or an equivalent length cap + de-dup) for the Obsidian filename, so to_obsidian truncates long names the same way the wiki exporter does.
Fixed in 690b4e5, shipping in the next release. Thanks for the precise diagnosis @felipeathayde - the wiki.py vs to_obsidian comparison made it easy to confirm.
Fix
Added a shared _cap_filename(s, limit=200) helper that both to_obsidian and to_canvas route their filenames through. Two things beyond a straight [:200] cap:
Caps on UTF-8 bytes, not chars. The FS limit is 255 bytes, and a label of CJK/accented characters hits that well under 255 chars (200 CJK chars ≈ 600 bytes). A char cap would still crash on multibyte labels. The helper truncates on a byte boundary with decode(..., "ignore") so it never splits a multibyte char.
Hash suffix on truncation. When a name is truncated it gets an 8-char sha1 of the full label appended, so two distinct labels sharing a long prefix produce distinct, deterministic filenames instead of silently overwriting each other.
Two extra sites your report didn't mention (also fixed)
The _COMMUNITY_<name>.md overview notes were built with no dedup dict at all, so two long community names sharing a prefix could overwrite. The hash suffix fixes that too.
to_canvas has its own copy of the same safe_name builder with the same uncapped bug - now capped via the same helper.
Wikilinks stay correct automatically because both the file write and the [[link]] read from the same node_filename dict.
Tests
Added tests/test_obsidian_filename_cap.py: 300-char ASCII, 300-char CJK (byte overflow), two distinct labels sharing a 200-char prefix (no collision), wikilink-resolves-after-truncation, and the canvas file-ref cap. Full suite green (1495 passed).
Activity
safishamsi commentedon May 31, 2026
Fixed in
690b4e5, shipping in the next release. Thanks for the precise diagnosis @felipeathayde - thewiki.pyvsto_obsidiancomparison made it easy to confirm.Fix
Added a shared
_cap_filename(s, limit=200)helper that bothto_obsidianandto_canvasroute their filenames through. Two things beyond a straight[:200]cap:Caps on UTF-8 bytes, not chars. The FS limit is 255 bytes, and a label of CJK/accented characters hits that well under 255 chars (200 CJK chars ≈ 600 bytes). A char cap would still crash on multibyte labels. The helper truncates on a byte boundary with
decode(..., "ignore")so it never splits a multibyte char.Hash suffix on truncation. When a name is truncated it gets an 8-char sha1 of the full label appended, so two distinct labels sharing a long prefix produce distinct, deterministic filenames instead of silently overwriting each other.
Two extra sites your report didn't mention (also fixed)
_COMMUNITY_<name>.mdoverview notes were built with no dedup dict at all, so two long community names sharing a prefix could overwrite. The hash suffix fixes that too.to_canvashas its own copy of the samesafe_namebuilder with the same uncapped bug - now capped via the same helper.Wikilinks stay correct automatically because both the file write and the
[[link]]read from the samenode_filenamedict.Tests
Added
tests/test_obsidian_filename_cap.py: 300-char ASCII, 300-char CJK (byte overflow), two distinct labels sharing a 200-char prefix (no collision), wikilink-resolves-after-truncation, and the canvas file-ref cap. Full suite green (1495 passed).cap obsidian/canvas filenames to avoid ENAMETOOLONG on long labels (f…
cap obsidian/canvas filenames to avoid ENAMETOOLONG on long labels (f…
fix(export): honor the target filesystem's NAME_MAX in export filenames
fix(export): honor the target filesystem's NAME_MAX in export filenames
fix(export): keep export filename budgets in bytes, even below the floor
fix(export): keep export filename budgets in bytes, even below the floor