Skip to content

fix(graph): resolve Literal collector items to the types of their values - #9895

Merged
lstein merged 4 commits into
invoke-ai:mainfrom
kevin9327:fix/collector-literal-item-types
Oct 18, 2026
Merged

lstein merged 4 commits into
invoke-ai:mainfrom
kevin9327:fix/collector-literal-item-types

Conversation

@kevin9327

@kevin9327 kevin9327 commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A node output typed as a Literal (e.g. max_seq_len: Literal[256, 512] on the FLUX / FLUX.2 model loaders) can't be fed into a Collect node. Collector validation treats the Literal's values as types and calls issubclass(256, ...), so validation crashes with TypeError: issubclass() arg 1 must be a class instead of accepting or rejecting the edge. On the enqueue path this happens while the Batch body is parsed, so the API returns a 500 rather than a 422 (the same failure mode discussed in #9858).

_resolve_item_input_types now resolves a Literal[...] item to the types of its values (Literal[256, 512] → int, Optional[Literal["a", "b"]] → str), so the existing subtype checks work as intended:

  • before: literal.value → collect.item → integer_collection.collection → TypeError (500 on enqueue)
  • after: accepted; wiring the same items into a string collection is rejected with the normal InvalidEdgeError / 422 "Collector outputs must connect to a collection input with a matching type"

Related Issues / Discussions

QA Instructions

Added a small test_literal invocation to tests/test_nodes.py and four tests to tests/test_node_graph.py:

  • Literal items into an int collection are accepted
  • Literal items into a string collection get a clean InvalidEdgeError
  • Optional[Literal[...]] items into a string collection are accepted
  • a Batch holding the mismatched graph raises ValidationError (not TypeError)

All four fail on main with TypeError: issubclass() arg 1 must be a class and pass with the fix.

pytest tests/test_node_graph.py tests/test_nodes.py tests/test_graph_execution_state.py tests/test_session_queue.py
410 passed, 2 xfailed
ruff check .          # All checks passed
ruff format --check   # clean for the changed files

Review

No material findings. Only collector item-type resolution changes; non-Literal types resolve exactly as before.

Checklist

  • The PR has a short but descriptive title, suitable for a changelog
  • Meaningful regression coverage added / updated where needed; obsolete tests/code removed
  • Persisted-state and API changes include required migrations / compatibility validation (n/a)
  • Relevant performance/efficiency opportunities considered; material claims have evidence
  • Material review findings resolved and relevant checks rerun
  • Documentation added / updated (if applicable) (n/a)
  • Updated What's New copy (if doing a release after this PR) (n/a)

AI-assisted: I used an AI assistant to help trace this and draft the change. I reviewed the code and tests and ran them locally.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-17T02:14:56.526213Z f590bd6 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions github-actions Bot added python PRs that change python files services PRs that change app services python-tests PRs that change python tests labels Oct 17, 2026
@JPPhoto
JPPhoto self-requested a review October 18, 2026 15:19
@lstein
lstein enabled auto-merge (squash) October 18, 2026 18:12
@lstein
lstein merged commit 7104b58 into invoke-ai:main Oct 18, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python PRs that change python files python-tests PRs that change python tests services PRs that change app services

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants