UnboundLocalError on a dangling symlink in custom_nodes

Open Beginner friendly
#18,171 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@harmehak0173 is already working on this.

Since Dec 5, 2026.

  • #18244 by @harmehak0173 — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
82/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
backend

Research direction

Start in nodes.py at load_custom_node, around the reported line 2271, and trace how it handles paths that are files or directories. Reproduce with ln -s /nonexistent custom_nodes/comfyui-ghost and start ComfyUI. Done means a dangling symlink is skipped with a warning instead of raising UnboundLocalError.

Written by the indexing model from the issue text.

Description

Custom Node Testing
Expected Behavior

A broken symlink in custom_nodes/ gets skipped with a warning that says what's wrong.

Actual Behavior

I had a symlink in custom_nodes/ whose target I'd deleted, and startup reported it as a failed import with an UnboundLocalError (see logs), which looks like a broken node. In load_custom_node, sys_module_name is only set in the isfile/isdir branches and a dangling link is neither. An else: that logs a skip warning and returns False fixes it for me. I can open a PR if you want.

Steps to Reproduce

ln -s /nonexistent custom_nodes/comfyui-ghost, then start ComfyUI.

Debug Logs
  File ".../nodes.py", line 2271, in load_custom_node
UnboundLocalError: cannot access local variable 'sys_module_name' where it is not associated with a value
WARNING Cannot import /.../custom_nodes/comfyui-ghost module for custom nodes: cannot access local variable 'sys_module_name' where it is not associated with a value
Other

No response

Dominant language
Python
Stars
150k
Forks
17.9k
Avg merge
1d 1h
Merged PRs (30d)
181

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Comfy-Org/ComfyUI

All issues in Comfy-Org/ComfyUI

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.