[GH-ISSUE #16] Multiple image inputs collapse to "last image wins" in submitJob #3

Open
opened 2026-10-26 22:33:42 +00:00 by bsakaguchi · 1 comment
Owner

Originally created by @mattmillerai on GitHub (Jun 21, 2026).
Original GitHub issue: https://github.com/Comfy-Org/comfy-swift-sdk/issues/16

Surfaced by CodeRabbit on #10 (pre-existing logic; tracked here, not fixed in that comment-only PR).

`Transport.submitJob` loops over `request.inputs` and, for each `.image`, calls `patchLoadImageNodes(...)` which rewrites every `LoadImage` node in the workflow JSON. With more than one image input, each iteration overwrites the previous binding, so all `LoadImage` nodes end up pointing at the last uploaded filename.

Options:

  1. Keyed mapping — associate each image input (by index/identifier) with a specific `LoadImage` node and patch only that node.
  2. Interim guard — reject >1 image input with a clear `ComfyError` until keyed mapping exists:

```swift
if request.inputs.filter({ if case .image = $0 { return true }; return false }).count > 1 {
throw ComfyError.serverRejected(reason: .other("Multiple image inputs are not yet supported in a single request"))
}
```

Acceptance: a two-image request either binds each to its intended node, or fails fast with a descriptive error (no silent last-wins). Add a unit test covering the multi-image case.

Originally created by @mattmillerai on GitHub (Jun 21, 2026). Original GitHub issue: https://github.com/Comfy-Org/comfy-swift-sdk/issues/16 Surfaced by CodeRabbit on #10 (pre-existing logic; tracked here, not fixed in that comment-only PR). \`Transport.submitJob\` loops over \`request.inputs\` and, for each \`.image\`, calls \`patchLoadImageNodes(...)\` which rewrites **every** \`LoadImage\` node in the workflow JSON. With more than one image input, each iteration overwrites the previous binding, so all \`LoadImage\` nodes end up pointing at the **last** uploaded filename. **Options:** 1. Keyed mapping — associate each image input (by index/identifier) with a specific \`LoadImage\` node and patch only that node. 2. Interim guard — reject >1 image input with a clear \`ComfyError\` until keyed mapping exists: \`\`\`swift if request.inputs.filter({ if case .image = $0 { return true }; return false }).count > 1 { throw ComfyError.serverRejected(reason: .other("Multiple image inputs are not yet supported in a single request")) } \`\`\` **Acceptance:** a two-image request either binds each to its intended node, or fails fast with a descriptive error (no silent last-wins). Add a unit test covering the multi-image case.
Author
Owner

@mattmillerai commented on GitHub (Jun 21, 2026):

Interim guard merged in #22: submitJob now fails fast with ComfyError.serverRejected(.other("multiple_image_inputs_unsupported")) on >1 image input, so the silent "last image wins" behaviour is gone.

Remaining scope for this issue (kept open): keyed input→node mapping — associate each image input with a specific LoadImage node (by index/identifier) and patch only that node, so multi-image requests bind correctly instead of being rejected. Good candidate for 0.2.0.

<!-- gh-comment-id:4763536353 --> @mattmillerai commented on GitHub (Jun 21, 2026): Interim guard merged in #22: `submitJob` now fails fast with `ComfyError.serverRejected(.other("multiple_image_inputs_unsupported"))` on >1 image input, so the silent "last image wins" behaviour is gone. **Remaining scope for this issue** (kept open): keyed input→node mapping — associate each image input with a specific `LoadImage` node (by index/identifier) and patch only that node, so multi-image requests bind correctly instead of being rejected. Good candidate for 0.2.0.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Comfy-Org/comfy-swift-sdk#3
No description provided.