[GH-ISSUE #2437] [Issue]: 11-PROV-ASSET-image-output-normalization drops normalized image extension #1192

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

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

Originally assigned to: @SpicyMarinara on GitHub.

Summary

11-PROV-ASSET-image-output-normalization has a parity gap: refactor image provider transport returns base64 and mimeType, but no normalized file extension, and some data URL / JSON base64 paths pass through provider data without the legacy decode, validation, and re-encode normalization before storage callers save assets.

Links back to #2410.

Expected behavior

Legacy main normalizes image provider outputs into { base64, mimeType, ext }. Data URLs are decoded, validated, re-encoded, and mapped to an extension before callers save files.

Actual behavior

Refactor Rust provider transport returns (base64, mime) and the public image_generate command emits base64, mimeType, and image, but no ext. Several JSON/data URL base64 extraction paths validate size only and preserve provider-declared MIME/base64 text without the same legacy decode/re-encode normalization.

Steps to reproduce

  1. Static-trace 11-PROV-ASSET-image-output-normalization from #2410.
  2. Compare legacy packages/server/src/services/image/image-generation.ts result normalization with refactor src-tauri/src/commands/storage/images/providers.rs and src-tauri/src/commands/storage/images.rs.
  3. Follow direct storage callers that derive filenames from mimeType after image_generate.

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: refactor parityscan for #2410, static trace on 2026-06-06
  • Run mode: Tauri desktop / remote runtime image provider transport
  • OS + version: not runtime-tested
  • Node + pnpm versions: not relevant
  • Rust version, if relevant: not runtime-tested
  • Remote Runtime URL configured? not relevant
  • Provider, model, or integration, if relevant: image-generation providers returning base64, data URLs, URLs, or JSON image references

Logs, screenshots, or video

Proof used: static trace only.

Files inspected:

  • Legacy: packages/server/src/services/image/image-generation.ts:99, :390, :519, :565, :977, :1187, :1412, :1774, :1916
  • Legacy: packages/server/src/services/game/game-asset-generation.ts:92
  • Refactor: src-tauri/src/commands/storage/images/providers.rs:58, :543, :1462, :2768
  • Refactor: src-tauri/src/commands/storage/images.rs:186
  • Refactor direct caller: src/features/catalog/gallery/hooks/use-gallery.ts:157

Regression notes

Legacy ImageGenResult carried base64, mimeType, and ext; game asset saving could also fall back through byte detection and ext/MIME normalization. Refactor loses the ext part of the normalized transport result before some callers save assets.

Additional context

Acceptance criteria:

  • 11-PROV-ASSET-image-output-normalization provider outputs normalize base64, mimeType, and file extension before storage callers save assets.
  • Data URL, returned URL download, JSON base64, and JSON image-reference paths decode/validate/re-encode image bytes consistently with legacy behavior.
  • Saved filenames/extensions remain correct for PNG, JPEG, WebP, and GIF where provider output supports those formats.
  • The no-gap 11-PROV-ASSET-image-reference-transport behavior is preserved.

11-PROV-ASSET-image-reference-transport was scanned in the same batch and did not have a confirmed parity gap.

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 @Promansis on GitHub (Jun 6, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2437 Originally assigned to: @SpicyMarinara on GitHub. ## Summary `11-PROV-ASSET-image-output-normalization` has a parity gap: refactor image provider transport returns `base64` and `mimeType`, but no normalized file extension, and some data URL / JSON base64 paths pass through provider data without the legacy decode, validation, and re-encode normalization before storage callers save assets. Links back to #2410. ## Expected behavior Legacy `main` normalizes image provider outputs into `{ base64, mimeType, ext }`. Data URLs are decoded, validated, re-encoded, and mapped to an extension before callers save files. ## Actual behavior Refactor Rust provider transport returns `(base64, mime)` and the public `image_generate` command emits `base64`, `mimeType`, and `image`, but no `ext`. Several JSON/data URL base64 extraction paths validate size only and preserve provider-declared MIME/base64 text without the same legacy decode/re-encode normalization. ## Steps to reproduce 1. Static-trace `11-PROV-ASSET-image-output-normalization` from #2410. 2. Compare legacy `packages/server/src/services/image/image-generation.ts` result normalization with refactor `src-tauri/src/commands/storage/images/providers.rs` and `src-tauri/src/commands/storage/images.rs`. 3. Follow direct storage callers that derive filenames from `mimeType` after `image_generate`. ## Impact area <!-- Check the areas you think are relevant. Leave uncertain items unchecked. --> - [ ] App shell, navigation, startup, or providers - [ ] Catalog resources - [ ] Chat mode - [ ] Roleplay mode - [ ] Game mode - [ ] Shared mode UI - [x] 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: refactor parityscan for #2410, static trace on 2026-06-06 - Run mode: Tauri desktop / remote runtime image provider transport - OS + version: not runtime-tested - Node + pnpm versions: not relevant - Rust version, if relevant: not runtime-tested - Remote Runtime URL configured? not relevant - Provider, model, or integration, if relevant: image-generation providers returning base64, data URLs, URLs, or JSON image references ## Logs, screenshots, or video Proof used: static trace only. Files inspected: - Legacy: `packages/server/src/services/image/image-generation.ts:99`, `:390`, `:519`, `:565`, `:977`, `:1187`, `:1412`, `:1774`, `:1916` - Legacy: `packages/server/src/services/game/game-asset-generation.ts:92` - Refactor: `src-tauri/src/commands/storage/images/providers.rs:58`, `:543`, `:1462`, `:2768` - Refactor: `src-tauri/src/commands/storage/images.rs:186` - Refactor direct caller: `src/features/catalog/gallery/hooks/use-gallery.ts:157` ## Regression notes Legacy `ImageGenResult` carried `base64`, `mimeType`, and `ext`; game asset saving could also fall back through byte detection and `ext`/MIME normalization. Refactor loses the `ext` part of the normalized transport result before some callers save assets. ## Additional context Acceptance criteria: - `11-PROV-ASSET-image-output-normalization` provider outputs normalize `base64`, `mimeType`, and file extension before storage callers save assets. - Data URL, returned URL download, JSON base64, and JSON image-reference paths decode/validate/re-encode image bytes consistently with legacy behavior. - Saved filenames/extensions remain correct for PNG, JPEG, WebP, and GIF where provider output supports those formats. - The no-gap `11-PROV-ASSET-image-reference-transport` behavior is preserved. `11-PROV-ASSET-image-reference-transport` was scanned in the same batch and did not have a confirmed parity gap. ## 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-21 05:28:36 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

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

Fixed on refactor in commit 3ac37e0a.

What changed:

  • Image provider outputs now decode and re-encode base64/data URL image bytes through the shared normalization helper.
  • Direct binary responses, fetched image URLs, JSON base64 fields, data URLs, Automatic1111/Horde strings, RunPod extraction, Google image fields, and NovelAI binary/zip image paths now flow through normalized image bytes where applicable.
  • Normalized MIME is derived from image bytes when possible, with supported declared MIME fallback, and public image commands now include ext beside base64, mimeType, and image.
  • Gallery regeneration, game asset uploads, generated illustrations, and generated portraits prefer the normalized ext while keeping MIME fallback behavior.

Verification:

  • cargo check --manifest-path src-tauri/Cargo.toml --workspace
  • pnpm typecheck
  • cargo test --manifest-path src-tauri/Cargo.toml -p marinara-engine image_ -- --nocapture
  • pnpm check:architecture
<!-- gh-comment-id:4638136843 --> @SpicyMarinara commented on GitHub (Jun 6, 2026): Fixed on refactor in commit 3ac37e0a. What changed: - Image provider outputs now decode and re-encode base64/data URL image bytes through the shared normalization helper. - Direct binary responses, fetched image URLs, JSON base64 fields, data URLs, Automatic1111/Horde strings, RunPod extraction, Google image fields, and NovelAI binary/zip image paths now flow through normalized image bytes where applicable. - Normalized MIME is derived from image bytes when possible, with supported declared MIME fallback, and public image commands now include ext beside base64, mimeType, and image. - Gallery regeneration, game asset uploads, generated illustrations, and generated portraits prefer the normalized ext while keeping MIME fallback behavior. Verification: - cargo check --manifest-path src-tauri/Cargo.toml --workspace - pnpm typecheck - cargo test --manifest-path src-tauri/Cargo.toml -p marinara-engine image_ -- --nocapture - pnpm check:architecture
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#1192
No description provided.