Skip to content

sanitize_label crashes when node source_file is None (export.py:392) #454

Closed

Description

@vadafino1

Summary

graphify/export.py:392 calls sanitize_label(data.get("source_file", "")). When a node's source_file attribute is explicitly set to None (rather than the key being absent), dict.get returns None and sanitize_label raises TypeError: expected string or bytes-like object, got NoneType.

This happens in practice with concept nodes lifted from code AST — they carry an explicit source_file=None rather than omitting the key.

Repro

graphify <any code repo> --directed

Fails during the vis-network HTML build step.

Stack shape

File ".../graphify/export.py", line 392, in <listcomp>
    "source_file": sanitize_label(data.get("source_file", "")),
File ".../graphify/security.py", line ...
TypeError: expected string or bytes-like object, got NoneType

One-line fix

Swap the dict.get default for an or "" fallback so both the missing-key and explicit-None cases are handled:

"source_file": sanitize_label(data.get("source_file") or ""),

Same pattern applies at export.py:548 and export.py:642 where data.get("source_file", "") is used — they don't currently crash because the result is only string-concatenated, but will surface as "None" in output.

Local workaround

Currently patched client-side via a SKILL.md override in my Claude Code harness (walks G.nodes and rewrites None source_file/label/file_type to empty strings before calling to_html).

Activity

  1. added a commit that references this issue on Apr 21, 2026
    bba301b
  2. added a commit that references this issue on Apr 23, 2026
    81b6e7d
  3. added a commit that references this issue on Sep 10, 2026
    1f1e8f9
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