Skip to content

TypeError in export wiki: '<' not supported between str and NoneType when source_file is None #1016

Closed

Description

@guilherme-campanholi

Version

graphify 0.8.15

Command

graphify export wiki

Error

File ".../graphify/wiki.py", line 57, in _community_article
    sources = sorted({G.nodes[n].get("source_file", "") for n in nodes} - {""})
TypeError: '<' not supported between instances of 'str' and 'NoneType'

Root Cause

Some nodes in graph.json have source_file: null (not "" or missing key). The set comprehension uses .get("source_file", "") which only applies the default for missing keys — when the key exists with value null/None, it returns None. Subtracting {""} does not remove None, so sorted({"a", None, "b"}) raises TypeError.

This happens after an incremental extraction where some semantic chunks fail mid-run (e.g. credit exhaustion, rate limit), leaving partially-extracted nodes with source_file=None.

Fix (one-liner)

# wiki.py line 57 — before:
sources = sorted({G.nodes[n].get("source_file", "") for n in nodes} - {""})

# after:
sources = sorted({(G.nodes[n].get("source_file") or "") for n in nodes} - {""})

Using or "" coerces both None and "" to "", which is then removed by - {""}. Sorting the result is always safe.

Workaround applied locally

Patched wiki.py in the venv as above. graphify export wiki now runs successfully with the patched version.

Reproducibility

Trigger a full extraction (graphify . --backend claude) and force an early abort (e.g. exhaust API credits mid-run). Some nodes will have source_file: null in the resulting graph.json. Then run graphify export wiki — it crashes.

Activity

  1. safishamsi commented on May 26, 2026

    @safishamsi
    Member

    Fixed in 4e80d86 — changed .get('source_file', '') to (... or '') in wiki.py so None values are normalized before sorted() is called.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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