Skip to content

fix: guard against KeyError on unregistered class_type in _is_intermediate_output#13552

Open
cest-la-v wants to merge 3 commits intoComfy-Org:masterfrom
cest-la-v:fix/guard-unregistered-class-type
Open

fix: guard against KeyError on unregistered class_type in _is_intermediate_output#13552
cest-la-v wants to merge 3 commits intoComfy-Org:masterfrom
cest-la-v:fix/guard-unregistered-class-type

Conversation

@cest-la-v
Copy link
Copy Markdown

@cest-la-v cest-la-v commented Apr 24, 2026

Summary

_is_intermediate_output (introduced in 3696c5b) iterates over all node IDs in the prompt after execution, including orphaned/disconnected nodes that were never validated or executed. If any such node's class_type is absent from NODE_CLASS_MAPPINGS (e.g. a custom node pack that failed to load, was renamed, or was removed), the direct dict lookup raises KeyError.

This exception short-circuits the while...else block and prevents:

  • execution_success from being sent to the frontend
  • self.history_result from being assigned

Images are still saved to disk (since SaveImage runs during the main execution loop), but the Gallery never receives the success event and /history returns incomplete data — a silent failure that is hard to diagnose.

Fix

Replace NODE_CLASS_MAPPINGS[class_type] with .get(class_type) and guard on None, so unregistered nodes are silently treated as non-intermediate-output nodes and execution continues normally.

Commit 3696c5b introduced _is_intermediate_output which iterates over
all node IDs in the prompt after execution, including orphan/disconnected
nodes that are never validated or executed. If any such node's class_type
is not in NODE_CLASS_MAPPINGS (e.g. a custom node pack that failed to
load or was renamed), NODE_CLASS_MAPPINGS[class_type] raises KeyError.

This exception short-circuits the while...else block, preventing:
- execution_success from being sent to the frontend
- self.history_result from being assigned

Images are still saved to disk since SaveImage runs during the main
execution loop, but the Gallery plugin never receives the success event
and the /history API returns incomplete data.

Fix: use .get() with a None guard so unregistered nodes are silently
treated as non-intermediate-output nodes.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 24, 2026

📝 Walkthrough

Walkthrough

The execution.py file has been modified to improve error handling in the intermediate-output detection logic. The _is_intermediate_output function now uses the safe dictionary retrieval method NODE_CLASS_MAPPINGS.get(...) to handle cases where a class_type value is unknown or missing. When the node class definition is absent, the function returns False instead of raising an exception. This change affects only the intermediate-output detection path while leaving other execution paths unmodified.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title accurately describes the main change: guarding against KeyError when unregistered class_type values are encountered in _is_intermediate_output.
Description check ✅ Passed The description provides detailed context about the issue, its impact, and the fix implemented in this changeset.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cest-la-v cest-la-v changed the title fix: guard against unregistered class_type in _is_intermediate_output fix: guard against KeyError on unregistered class_type in _is_intermediate_output Apr 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants