[PR #802] [MERGED] Fix generated game asset filename length #4774

Closed
opened 2026-10-22 04:10:32 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/802
Author: @cha1latte
Created: 5/13/2026
Status: ✅ Merged
Merged: 5/13/2026
Merged by: @cha1latte

Base: main ← Head: fix/issue-790-safe-background-filenames


📝 Commits (1)

  • c880e68 Fix generated game asset filename length

📊 Changes

2 files changed (+47 additions, -4 deletions)

View changed files

📝 packages/server/src/services/game/game-asset-generation.ts (+29 -4)
➕ packages/server/test/game-asset-generation.test.ts (+18 -0)

📄 Description

Linked issue

Closes #790

Why this change

  • Game Mode scene illustrations can receive long scene-analyzer slugs, and those slugs were being used directly as generated background filenames. On Android/Termux this could exceed the 255-byte filename limit and prevent the image from saving with ENAMETOOLONG.

What changed

  • Added a shared generated-asset slug helper that sanitizes names, caps the byte length, and appends a short hash when truncation is needed.
  • Applied that helper to generated game backgrounds, roleplay chat backgrounds, and rare scene illustrations before constructing filesystem filenames.
  • Added a focused regression test for the issue slug and for short readable slugs.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Manual verification notes

  • Codex reproduced the issue filename with pnpm --dir packages/server exec tsx ../../scratch/issue-790-filename-repro.ts before: the generated filename was 293 bytes, above the 255-byte Android/Termux filename limit.
  • Codex re-ran the same repro after the fix with pnpm --dir packages/server exec tsx ../../scratch/issue-790-filename-repro.ts after: the generated filename was 184 bytes, below the 255-byte limit, and the write succeeded.
  • Codex ran pnpm --dir packages/server exec tsx --import ./test/setup-env.ts --test test/game-asset-generation.test.ts: 2 tests passed.
  • Codex ran pnpm check: passed.
  • No true human-only verification is required for the core filename-length claim. An Android/Termux runtime smoke test would still be useful as an environment regression check, but the core slug/filename limit is proven by the script and regression test.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Version/release files updated (only if this PR includes a version bump)

No docs or release metadata changes needed; this is a narrow server-side filename safety fix.

UI evidence (if applicable)

N/A - this is not a visual/UI issue. The proof is command output from the filename-limit repro and server regression test.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/802 **Author:** [@cha1latte](https://github.com/cha1latte) **Created:** 5/13/2026 **Status:** ✅ Merged **Merged:** 5/13/2026 **Merged by:** [@cha1latte](https://github.com/cha1latte) **Base:** `main` ← **Head:** `fix/issue-790-safe-background-filenames` --- ### 📝 Commits (1) - [`c880e68`](https://github.com/Pasta-Devs/Marinara-Engine/commit/c880e68f4db5f5b935beb7ebb49ae871a2777f83) Fix generated game asset filename length ### 📊 Changes **2 files changed** (+47 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `packages/server/src/services/game/game-asset-generation.ts` (+29 -4) ➕ `packages/server/test/game-asset-generation.test.ts` (+18 -0) </details> ### 📄 Description ## Linked issue <!-- Every PR should reference a feature request or issue report. If there isn't one yet, open one first to gather opinions: --> <!-- https://github.com/Pasta-Devs/Marinara-Engine/issues/new/choose --> Closes #790 ## Why this change <!-- What user problem, bug, or goal does this solve? --> - Game Mode scene illustrations can receive long scene-analyzer slugs, and those slugs were being used directly as generated background filenames. On Android/Termux this could exceed the 255-byte filename limit and prevent the image from saving with `ENAMETOOLONG`. ## What changed <!-- List the key changes in this PR --> - Added a shared generated-asset slug helper that sanitizes names, caps the byte length, and appends a short hash when truncation is needed. - Applied that helper to generated game backgrounds, roleplay chat backgrounds, and rare scene illustrations before constructing filesystem filenames. - Added a focused regression test for the issue slug and for short readable slugs. ## Validation <!-- Required: include commands run and/or manual checks performed --> - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` ### Manual verification notes <!-- Describe exactly what you tested in a real browser/app, step by step. --> <!-- ⚠️ If an AI agent filled out or ticked these boxes for you, treat them --> <!-- as a TO-DO LIST, not as proof the work is done. Verify each item yourself --> <!-- before submitting. If you haven't verified it, untick the box. --> - Codex reproduced the issue filename with `pnpm --dir packages/server exec tsx ../../scratch/issue-790-filename-repro.ts before`: the generated filename was 293 bytes, above the 255-byte Android/Termux filename limit. - Codex re-ran the same repro after the fix with `pnpm --dir packages/server exec tsx ../../scratch/issue-790-filename-repro.ts after`: the generated filename was 184 bytes, below the 255-byte limit, and the write succeeded. - Codex ran `pnpm --dir packages/server exec tsx --import ./test/setup-env.ts --test test/game-asset-generation.test.ts`: 2 tests passed. - Codex ran `pnpm check`: passed. - No true human-only verification is required for the core filename-length claim. An Android/Termux runtime smoke test would still be useful as an environment regression check, but the core slug/filename limit is proven by the script and regression test. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Version/release files updated (only if this PR includes a version bump) No docs or release metadata changes needed; this is a narrow server-side filename safety fix. ## UI evidence (if applicable) N/A - this is not a visual/UI issue. The proof is command output from the filename-limit repro and server regression test. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:10:32 +07:00
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#4774
No description provided.