[GH-ISSUE #2764] [Issue]: Image-generation connection defaults silently dropped on every save (params schema strips the imageGeneration key) #1402

Closed
opened 2026-10-21 05:33:13 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @kolacheee on GitHub (Jun 21, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2764

Originally assigned to: @SpicyMarinara on GitHub.

Summary

Every save of an image_generation connection's Local Image Defaults (steps, CFG, sampler, scheduler, seed, denoise, clip skip, style profile, NovelAI/A1111/ComfyUI prefixes) is silently and completely lost. The save flashes success, but the values never persist and image generation continues using built-in defaults. Findings #1 and #34 are the same root-cause bug verified from two angles.

Sub-bug: imageGeneration blob stripped by generation-params schema on save (new-bug)

(a) How it breaks the pipeline
The client stores image defaults nested under defaultParameters["imageGeneration"] (IMAGE_DEFAULTS_STORAGE_KEY === "imageGeneration"). The PUT /:id/default-parameters route validates the whole body with generationParametersSchema.partial().safeParse(raw) and persists parsed.data. generationParametersSchema is a plain z.object with no imageGeneration key and no .passthrough()/.catchall(), so Zod strips the unknown key: safeParse({imageGeneration:{...}}) returns success:true, data:{}. updateDefaultParameters then does a full overwrite (JSON.stringify(params) -> '{}'), destroying the prior image blob. On read-back the server's resolveConnectionImageDefaults reads params['imageGeneration'] (now undefined) and falls back to createDefaultImageGenerationProfile.

(b) Steps to replicate

  1. Create/edit an image_generation connection.
  2. Change any Local Image Default (e.g. steps, CFG, sampler).
  3. Click Save (you get a success flash).
  4. Reopen the editor — every field has reverted to defaults; image generation ignores the saved values.

(c) Code trace

  • ConnectionEditor.handleSave image branch (ConnectionEditor.tsx:423-435) -> buildImageDefaultParameters (ConnectionEditor.tsx:2714-2725) builds { imageGeneration: {...} }.
  • useSaveConnectionDefaults (use-connections.ts:168-178) PUTs verbatim.
  • Route validation generationParametersSchema.partial().safeParse(raw) (connections.routes.ts:295) — VERIFIED present at lines 286-309; the route has a special-case for raw === null/non-object but no imageGeneration allowance.
  • generationParametersSchema (prompt.schema.ts:37-66) has no imageGeneration key, no passthrough -> key stripped.
  • updateDefaultParameters (connections.storage.ts:256-261) full-overwrite to '{}'.
  • Read-back resolveConnectionImageDefaults (image-generation-defaults.ts:25-31) -> default profile.
    Kind: new-bug.

Suggested Fix

Do not route image-defaults bodies through generationParametersSchema. Either (a) detect/allow the imageGeneration key in the PUT route (dedicated image-defaults schema, or .passthrough()), or (b) read existing defaultParameters and merge validated generation keys into it rather than replacing with parsed.data, preserving unknown top-level keys (especially imageGeneration).

Template

  • Root cause confirmed in code
  • Fix preserves the imageGeneration blob on save round-trip
  • Manually verify image defaults persist after reopening the editor
  • Manually verify a saved sampler/steps value is honored by an actual image generation
  • pnpm check passes
  • No regression to text-LLM connection default-parameters saves

Affected files

  • packages/server/src/routes/connections.routes.ts
  • packages/server/src/services/storage/connections.storage.ts
  • packages/client/src/components/connections/ConnectionEditor.tsx
  • packages/shared/src/schemas/prompt.schema.ts
  • packages/server/src/services/image/image-generation-defaults.ts

Audit provenance

Found by a multi-agent re-review of the connection/preset subsystem (editors UI + send-pipeline) against the merged staging tree (Round 1 + round-2 gap sweep + completeness critic, each finding adversarially verified). The prior #2656-#2668 fixes were re-verified as HELD on their primary paths. Severity: HIGH.

AI-drafted from a static read; validation/test-plan boxes intentionally left UNCHECKED for a human to verify before close.

Originally created by @kolacheee on GitHub (Jun 21, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2764 Originally assigned to: @SpicyMarinara on GitHub. ## Summary Every save of an `image_generation` connection's Local Image Defaults (steps, CFG, sampler, scheduler, seed, denoise, clip skip, style profile, NovelAI/A1111/ComfyUI prefixes) is silently and completely lost. The save flashes success, but the values never persist and image generation continues using built-in defaults. Findings #1 and #34 are the same root-cause bug verified from two angles. ## Sub-bug: `imageGeneration` blob stripped by generation-params schema on save (new-bug) **(a) How it breaks the pipeline** The client stores image defaults nested under `defaultParameters["imageGeneration"]` (`IMAGE_DEFAULTS_STORAGE_KEY === "imageGeneration"`). The PUT `/:id/default-parameters` route validates the whole body with `generationParametersSchema.partial().safeParse(raw)` and persists `parsed.data`. `generationParametersSchema` is a plain `z.object` with no `imageGeneration` key and no `.passthrough()`/`.catchall()`, so Zod strips the unknown key: `safeParse({imageGeneration:{...}})` returns `success:true, data:{}`. `updateDefaultParameters` then does a full overwrite (`JSON.stringify(params)` -> `'{}'`), destroying the prior image blob. On read-back the server's `resolveConnectionImageDefaults` reads `params['imageGeneration']` (now undefined) and falls back to `createDefaultImageGenerationProfile`. **(b) Steps to replicate** 1. Create/edit an `image_generation` connection. 2. Change any Local Image Default (e.g. steps, CFG, sampler). 3. Click Save (you get a success flash). 4. Reopen the editor — every field has reverted to defaults; image generation ignores the saved values. **(c) Code trace** - `ConnectionEditor.handleSave` image branch (ConnectionEditor.tsx:423-435) -> `buildImageDefaultParameters` (ConnectionEditor.tsx:2714-2725) builds `{ imageGeneration: {...} }`. - `useSaveConnectionDefaults` (use-connections.ts:168-178) PUTs verbatim. - Route validation `generationParametersSchema.partial().safeParse(raw)` (connections.routes.ts:295) — VERIFIED present at lines 286-309; the route has a special-case for `raw === null`/non-object but no `imageGeneration` allowance. - `generationParametersSchema` (prompt.schema.ts:37-66) has no `imageGeneration` key, no passthrough -> key stripped. - `updateDefaultParameters` (connections.storage.ts:256-261) full-overwrite to `'{}'`. - Read-back `resolveConnectionImageDefaults` (image-generation-defaults.ts:25-31) -> default profile. Kind: new-bug. ## Suggested Fix Do not route image-defaults bodies through `generationParametersSchema`. Either (a) detect/allow the `imageGeneration` key in the PUT route (dedicated image-defaults schema, or `.passthrough()`), or (b) read existing `defaultParameters` and merge validated generation keys into it rather than replacing with `parsed.data`, preserving unknown top-level keys (especially `imageGeneration`). ## Template - [ ] Root cause confirmed in code - [ ] Fix preserves the `imageGeneration` blob on save round-trip - [ ] Manually verify image defaults persist after reopening the editor - [ ] Manually verify a saved sampler/steps value is honored by an actual image generation - [ ] `pnpm check` passes - [ ] No regression to text-LLM connection default-parameters saves --- ### Affected files - `packages/server/src/routes/connections.routes.ts` - `packages/server/src/services/storage/connections.storage.ts` - `packages/client/src/components/connections/ConnectionEditor.tsx` - `packages/shared/src/schemas/prompt.schema.ts` - `packages/server/src/services/image/image-generation-defaults.ts` ### Audit provenance Found by a multi-agent re-review of the connection/preset subsystem (editors UI + send-pipeline) against the merged `staging` tree (Round 1 + round-2 gap sweep + completeness critic, each finding adversarially verified). The prior #2656-#2668 fixes were re-verified as HELD on their primary paths. Severity: **HIGH**. > AI-drafted from a static read; validation/test-plan boxes intentionally left UNCHECKED for a human to verify before close.
Author
Owner

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

Fixed in PR #2747.\n\nThe default-parameters route still validates known text-generation fields through generationParametersSchema, but now explicitly carries the shared imageGeneration defaults envelope through the save payload before storage overwrite. That prevents image-generation connection defaults from being stripped to {} on save while keeping the existing text parameter validation path intact.\n\nDeferred pnpm/check validation until the end of the issue sweep per maintainer request.

<!-- gh-comment-id:4763376964 --> @SpicyMarinara commented on GitHub (Jun 21, 2026): Fixed in PR #2747.\n\nThe default-parameters route still validates known text-generation fields through generationParametersSchema, but now explicitly carries the shared imageGeneration defaults envelope through the save payload before storage overwrite. That prevents image-generation connection defaults from being stripped to {} on save while keeping the existing text parameter validation path intact.\n\nDeferred pnpm/check validation until the end of the issue sweep per maintainer request.
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#1402
No description provided.