[GH-ISSUE #1275] [Issue]: ComfyUI image gen only substitutes the first reference image; indexed placeholders (%reference_image_name_02%) leak as plaintext #621

Closed
opened 2026-10-20 17:30:52 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @GetBeholder on GitHub (May 26, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/1275

Originally assigned to: @cha1latte on GitHub.

Summary

When generating images through a ComfyUI connection whose workflow uses
multiple reference images, Marinara Engine only handles the first reference
image. Indexed reference placeholders such as %reference_image_name_01% and
%reference_image_name_02% are never substituted, so they are sent to ComfyUI as
literal text and ComfyUI rejects the input. With "Send character & persona
avatars as reference images" checked, the second avatar is effectively not sent.

Expected behavior

A ComfyUI workflow that uses multiple indexed reference placeholders
(%reference_image_name_01%, %reference_image_name_02%, …) should have each
placeholder substituted with its corresponding uploaded reference image (for
example the character avatar and the persona avatar). When a reference slot has
no image, the graceful/empty-pixel fallback should apply to every slot — not
only the first — so no placeholder is ever sent to ComfyUI as raw text.

Actual behavior

Only %reference_image_name% is substituted, and only with the first reference
image. Indexed placeholders (_01, _02, …) are not recognized and pass through
unchanged, so ComfyUI receives e.g. %reference_image_name_02% as plaintext and
throws an input error (there is no error for the first/_01). Per contributor
diagnosis, the empty-pixel fallback for a missing reference image also only
applies to the first reference image.

Steps to reproduce

  1. Configure a ComfyUI connection with a workflow that loads two reference
    images, using %reference_image_name_01% and %reference_image_name_02%.
  2. In an RP/Game scene, enable "Send character & persona avatars as reference
    images" and use the Illustrator agent (or chat image gen with two references).
  3. Generate. ComfyUI returns an input error because %reference_image_name_02%
    arrives as literal text; the first reference is fine.
  4. Change both placeholders to %reference_image_name% → image gen works, but
    only one image is used.

Workaround (reporter): use both %reference_image_name% and
%reference_image_name_01% together. Per contributor Yas, %reference_image_name%
is an alias for _01, so this sends the same image twice. Recommended as a
stopgap "until a proper fix is implemented."

Impact area

  • App shell, navigation, startup, or providers
  • Catalog resources
  • Chat mode
  • Roleplay mode
  • Game mode
  • Shared mode UI
  • Runtime systems: generation, world-state, visuals, tracker, or haptics
  • Professor Mari or shell tools
  • React-free engine behavior, contracts, agents, or capability ports
  • Shared API wrapper or remote runtime routing
  • Tauri/Rust storage, assets, LLM, integrations, security, imports, or HTTP runtime
  • Docs, contributor workflow, or templates

Environment

  • Branch or commit: v1.6.1
  • Run mode: Windows Installer (Tauri desktop)
  • OS + version: Windows 11 (browsers listed: Opera GX / Google Chrome)
  • Node + pnpm versions: not provided
  • Rust version, if relevant: not provided
  • Remote Runtime URL configured? not specified
  • Provider, model, or integration, if relevant: ComfyUI / Flux2 Klein 9b

Logs, screenshots, or video

The reporter attached a ComfyUI workflow file (ComfyUI_Workflow.txt, ~361
lines) and screenshots of the Illustrator agent and custom prompt in the
original thread. These were not provided here as files or URLs, so they are not
attached. The custom Illustrator agent prompt outputs a characters array used
to attach each character's / the persona's avatar as a visual reference, and the
reporter notes the workflow works correctly in ComfyUI directly and for
single-reference avatar generation in the character galleries.

Regression notes

Not provided.

Additional context

Source: forum thread started by FluffiStuf [DOKI] (1-Star), with diagnosis by
Pasta Contributor Yas (~May 25, 2026). Yas confirmed the empty-pixel fallback for
a missing reference only works for the first reference image, and recommended the
alias workaround until a proper fix lands.

Code pointer (from a scan, not from the reporter):
src-tauri/src/commands/storage/images/providers.rs → generate_comfyui (~L1620).
It builds workflow replacements using only options.reference_images.first()
(L1652) and substitutes only the %reference_image_name% token, again with
.first() (L1654-1661). There is no handling for indexed placeholders
(%reference_image_name_01/02/...%) or for additional reference images, so
multi-reference workflows leave the indexed tokens unsubstituted and
replace_workflow_placeholders passes the literal tokens through to ComfyUI.

Template check

Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @GetBeholder on GitHub (May 26, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/1275 Originally assigned to: @cha1latte on GitHub. ## Summary When generating images through a ComfyUI connection whose workflow uses multiple reference images, Marinara Engine only handles the first reference image. Indexed reference placeholders such as `%reference_image_name_01%` and `%reference_image_name_02%` are never substituted, so they are sent to ComfyUI as literal text and ComfyUI rejects the input. With "Send character & persona avatars as reference images" checked, the second avatar is effectively not sent. ## Expected behavior A ComfyUI workflow that uses multiple indexed reference placeholders (`%reference_image_name_01%`, `%reference_image_name_02%`, …) should have each placeholder substituted with its corresponding uploaded reference image (for example the character avatar and the persona avatar). When a reference slot has no image, the graceful/empty-pixel fallback should apply to every slot — not only the first — so no placeholder is ever sent to ComfyUI as raw text. ## Actual behavior Only `%reference_image_name%` is substituted, and only with the first reference image. Indexed placeholders (`_01`, `_02`, …) are not recognized and pass through unchanged, so ComfyUI receives e.g. `%reference_image_name_02%` as plaintext and throws an input error (there is no error for the first/`_01`). Per contributor diagnosis, the empty-pixel fallback for a missing reference image also only applies to the first reference image. ## Steps to reproduce 1. Configure a ComfyUI connection with a workflow that loads two reference images, using `%reference_image_name_01%` and `%reference_image_name_02%`. 2. In an RP/Game scene, enable "Send character & persona avatars as reference images" and use the Illustrator agent (or chat image gen with two references). 3. Generate. ComfyUI returns an input error because `%reference_image_name_02%` arrives as literal text; the first reference is fine. 4. Change both placeholders to `%reference_image_name%` → image gen works, but only one image is used. Workaround (reporter): use both `%reference_image_name%` and `%reference_image_name_01%` together. Per contributor Yas, `%reference_image_name%` is an alias for `_01`, so this sends the same image twice. Recommended as a stopgap "until a proper fix is implemented." ## Impact area - [ ] App shell, navigation, startup, or providers - [ ] Catalog resources - [ ] Chat mode - [ ] Roleplay mode - [ ] Game mode - [ ] Shared mode UI - [ ] Runtime systems: generation, world-state, visuals, tracker, or haptics - [ ] Professor Mari or shell tools - [ ] React-free engine behavior, contracts, agents, or capability ports - [ ] Shared API wrapper or remote runtime routing - [x] Tauri/Rust storage, assets, LLM, integrations, security, imports, or HTTP runtime - [ ] Docs, contributor workflow, or templates ## Environment - Branch or commit: v1.6.1 - Run mode: Windows Installer (Tauri desktop) - OS + version: Windows 11 (browsers listed: Opera GX / Google Chrome) - Node + pnpm versions: not provided - Rust version, if relevant: not provided - Remote Runtime URL configured? not specified - Provider, model, or integration, if relevant: ComfyUI / Flux2 Klein 9b ## Logs, screenshots, or video The reporter attached a ComfyUI workflow file (`ComfyUI_Workflow.txt`, ~361 lines) and screenshots of the Illustrator agent and custom prompt in the original thread. These were not provided here as files or URLs, so they are not attached. The custom Illustrator agent prompt outputs a `characters` array used to attach each character's / the persona's avatar as a visual reference, and the reporter notes the workflow works correctly in ComfyUI directly and for single-reference avatar generation in the character galleries. ## Regression notes Not provided. ## Additional context Source: forum thread started by FluffiStuf [DOKI] (1-Star), with diagnosis by Pasta Contributor Yas (~May 25, 2026). Yas confirmed the empty-pixel fallback for a missing reference only works for the first reference image, and recommended the alias workaround until a proper fix lands. Code pointer (from a scan, not from the reporter): `src-tauri/src/commands/storage/images/providers.rs` → `generate_comfyui` (~L1620). It builds workflow replacements using only `options.reference_images.first()` (L1652) and substitutes only the `%reference_image_name%` token, again with `.first()` (L1654-1661). There is no handling for indexed placeholders (`%reference_image_name_01/02/...%`) or for additional reference images, so multi-reference workflows leave the indexed tokens unsubstituted and `replace_workflow_placeholders` passes the literal tokens through to ComfyUI. ## Template check Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-20 17:30:52 +07:00
  • closed this issue
  • added the
    server
    bug
    labels
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
Pasta-Devs/Marinara-Engine#621
No description provided.