[GH-ISSUE #3796] [Issue]: Cyrillic (non-Latin) NPC names fail avatar upload with 400 "Invalid character name" #2048

Closed
opened 2026-10-21 05:44:53 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @Kuroame15 on GitHub (Jul 18, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/3796

Originally assigned to: @SpicyMarinara on GitHub.

Summary

Uploading an NPC avatar fails for any character whose name contains no Latin letters (Cyrillic, etc.) with 400 "Invalid character name". The Present Characters tracker accepts these names fine, but avatar upload rejects them.

Expected behavior

The avatar uploads successfully regardless of the character's name script, just as the tracker already accepts non-Latin names.

Actual behavior

The upload returns 400 { error: "Invalid character name" } and the image is never saved.

Steps to reproduce

  1. In a Roleplay chat, have an NPC with a Cyrillic name (e.g. "Корвин") in the Present Characters tracker.
  2. Click "Upload tracker art" and pick any image.
  3. Request POST /api/avatars/npc/{chatId} with body { name: "Корвин", avatar: "data:image/jpeg;base64,..." } returns 400 { error: "Invalid character name" }.

Environment

  • Marinara Engine version: 2.3.3
  • Install type: Windows installer (installed from Marinara-Engine-Installer-2.3.1.exe, auto-updated to 2.3.3)
  • OS + version: Windows 10 Pro 22H2 (build 19045.6456)
  • Browser or app shell: Google Chrome 150 (64-bit)

Logs, screenshots, or video

Request: POST /api/avatars/npc/{chatId}
Body: { name: "Корвин", avatar: "data:image/jpeg;base64,..." }
Response: 400 { error: "Invalid character name" }

Additional context

Cause is in packages/server/src/routes/avatars.routes.ts, POST /npc/:chatId:

const safeName = name
  .toLowerCase()
  .replace(/[^a-z0-9]+/g, "-")
  .replace(/(^-|-$)/g, "");

The [^a-z0-9] class turns every Cyrillic character into "-", the trailing replace strips them, safeName becomes "", and the handler returns 400 before the image is ever checked.

Suggested one-line fix — make the class Unicode-aware:

.replace(/[^\p{L}\p{N}]+/gu, "-")

Alternatively, hash the name for the on-disk filename to keep it ASCII-safe, since avatars are already served by internal id.

Workaround: temporarily rename the NPC to Latin, upload, then rename back — the avatar sticks by internal id.

Template check

  • I DID NOT read this template and provide the requested details.
Originally created by @Kuroame15 on GitHub (Jul 18, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/3796 Originally assigned to: @SpicyMarinara on GitHub. ## Summary Uploading an NPC avatar fails for any character whose name contains no Latin letters (Cyrillic, etc.) with 400 "Invalid character name". The Present Characters tracker accepts these names fine, but avatar upload rejects them. ## Expected behavior The avatar uploads successfully regardless of the character's name script, just as the tracker already accepts non-Latin names. ## Actual behavior The upload returns 400 { error: "Invalid character name" } and the image is never saved. ## Steps to reproduce 1. In a Roleplay chat, have an NPC with a Cyrillic name (e.g. "Корвин") in the Present Characters tracker. 2. Click "Upload tracker art" and pick any image. 3. Request POST /api/avatars/npc/{chatId} with body { name: "Корвин", avatar: "data:image/jpeg;base64,..." } returns 400 { error: "Invalid character name" }. ## Environment - Marinara Engine version: 2.3.3 - Install type: Windows installer (installed from Marinara-Engine-Installer-2.3.1.exe, auto-updated to 2.3.3) - OS + version: Windows 10 Pro 22H2 (build 19045.6456) - Browser or app shell: Google Chrome 150 (64-bit) ## Logs, screenshots, or video Request: POST /api/avatars/npc/{chatId} Body: { name: "Корвин", avatar: "data:image/jpeg;base64,..." } Response: 400 { error: "Invalid character name" } ## Additional context Cause is in packages/server/src/routes/avatars.routes.ts, POST /npc/:chatId: const safeName = name .toLowerCase() .replace(/[^a-z0-9]+/g, "-") .replace(/(^-|-$)/g, ""); The [^a-z0-9] class turns every Cyrillic character into "-", the trailing replace strips them, safeName becomes "", and the handler returns 400 before the image is ever checked. Suggested one-line fix — make the class Unicode-aware: .replace(/[^\p{L}\p{N}]+/gu, "-") Alternatively, hash the name for the on-disk filename to keep it ASCII-safe, since avatars are already served by internal id. Workaround: temporarily rename the NPC to Latin, upload, then rename back — the avatar sticks by internal id. ## Template check - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 05:44:53 +07:00
  • closed this issue
  • added the
    in-pr
    bug
    labels
Author
Owner

@SpicyMarinara commented on GitHub (Jul 18, 2026):

Claimed in draft PR #3800 on branch agent/issue-sweep-2026-07-19.

<!-- gh-comment-id:5013107787 --> @SpicyMarinara commented on GitHub (Jul 18, 2026): Claimed in draft PR #3800 on branch `agent/issue-sweep-2026-07-19`.
Author
Owner

@SpicyMarinara commented on GitHub (Jul 18, 2026):

Addressed in #3800. NPC avatar upload and lookup now reuse a Unicode-aware slug helper across upload, chat, generation, and Game routes; Cyrillic upload/lookup is covered by E2E and final CI is green.

<!-- gh-comment-id:5013302810 --> @SpicyMarinara commented on GitHub (Jul 18, 2026): Addressed in #3800. NPC avatar upload and lookup now reuse a Unicode-aware slug helper across upload, chat, generation, and Game routes; Cyrillic upload/lookup is covered by E2E and final CI is green.
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#2048
No description provided.