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 wiki: a community relabelled only by case loses its article on case-insensitive filesystems (orphan sweep compares names case-sensitively) #4508
On a case-insensitive filesystem (the macOS APFS default; also NTFS), to_wiki deletes a community's article when the community's label changes only in letter case between two exports, for example groups → Groups. index.md still links to Groups.md, which no longer exists.
The cause is the end-of-run orphan sweep in graphify/wiki.py (to_wiki, around line 451):
produced contains Groups.md. On a case-preserving, case-insensitive filesystem, the existing directory entry keeps its old name, groups.md: the atomic write replaces the file's contents but not the name's case. "groups.md" not in {"Groups.md"} is true, so the sweep unlinks groups.md, which is the very file this run just wrote.
Expected: the article survives, ideally under the new case, and the link in index.md resolves.
_unique_slug already folds case when it checks for collisions, so the sweep looks like the one remaining case-sensitive comparison. Possible fixes:
compare folded names, e.g. old_article.name.casefold() not in {p.casefold() for p in produced};
or skip any path that os.path.samefiles a produced one.
To get the new case onto disk as well, rename case-only changes before writing.
The end-of-run sweep arrived with the #3060 fix. The earlier up-front unlink, as I understand it, didn't have this problem.
In practice it happens when graphify label or a manual relabel changes only the case of a community name, or when re-clustering gives a community a hub-derived name that differs only in case.
Only the export that changes the case loses the article. The next export with the same labels writes it again, so the wiki stays broken until another export runs.
I could reproduce it directly on Windows NTFS, which is the case-insensitive side of the problem: groups -> Groups leaves index.md linking to a Groups.md that no longer exists.
Worth noting for anyone reading: _unique_slug in the same function already folds case when it dedups colliding labels, and its comment names APFS/NTFS explicitly. So the sweep really was the one remaining case-sensitive comparison, exactly as you suggested — the fix is that plus a two-step rename, because on a case-insensitive filesystem groups.md and Groups.md are the same file and a direct rename() is a no-op that leaves the old case on disk.
I kept a test asserting that a genuinely stale article is still swept, so the fix cannot drift into "never delete anything".
Activity
github-actions commentedon Oct 17, 2026
Thanks for opening this issue, @nzabate. A maintainer will take a look soon.
If you would like to discuss it in real time, come say hi on our Discord server. For longer-form questions and ideas there is also GitHub Discussions.
To help us triage, please make sure the report includes what you expected, what actually happened, and the steps (and a small sample) to reproduce it.
dupeisen commentedon Oct 26, 2026
Sent #4798 for this.
I could reproduce it directly on Windows NTFS, which is the case-insensitive side of the problem:
groups->Groupsleavesindex.mdlinking to aGroups.mdthat no longer exists.Worth noting for anyone reading:
_unique_slugin the same function already folds case when it dedups colliding labels, and its comment names APFS/NTFS explicitly. So the sweep really was the one remaining case-sensitive comparison, exactly as you suggested — the fix is that plus a two-step rename, because on a case-insensitive filesystemgroups.mdandGroups.mdare the same file and a directrename()is a no-op that leaves the old case on disk.I kept a test asserting that a genuinely stale article is still swept, so the fix cannot drift into "never delete anything".
fix(wiki): unlink the stale twin on case-sensitive filesystems, don't…
fix(wiki): keep the article when a community is relabelled only by case