Skip to content

AttributeError in _score_nodes when source_file is None #323

Closed

Description

@ross-jill-ws

Bug

graphify query crashes with an AttributeError when a node in the graph has source_file explicitly set to None.

Traceback

Traceback (most recent call last):
  File ".pyenv/versions/3.11.6/bin/graphify", line 8, in <module>
    sys.exit(main())
  File ".pyenv/versions/3.11.6/lib/python3.11/site-packages/graphify/__main__.py", line 510, in main
    scored = _score_nodes(G, terms)
  File ".pyenv/versions/3.11.6/lib/python3.11/site-packages/graphify/serve.py", line 38, in _score_nodes
    source = data.get("source_file", "").lower()
AttributeError: 'NoneType' object has no attribute 'lower'

Root cause

In serve.py line 37-38, data.get("source_file", "") returns None when the key exists but its value is None. The .get() default only applies when the key is missing, not when it's present with a None value.

# Current (broken)
label = data.get("label", "").lower()
source = data.get("source_file", "").lower()

# Fix
label = (data.get("label") or "").lower()
source = (data.get("source_file") or "").lower()

Steps to reproduce

  1. Build a graph where at least one node has source_file: None (e.g. a synthesized or community node)
  2. Run graphify query "any search term"

Environment

  • Python 3.11.6
  • graphify installed via pip

Activity

  1. safishamsi commented on Apr 14, 2026

    @safishamsi
    Member

    Fixed in v0.4.13.

    Three locations in the MCP server were calling .lower() on values that could be None — source_file, label in _score_nodes, and label in _find_node and _tool_get_node. All three now guard with or "" before the string operation.

    pip install -U graphifyy
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