[GH-ISSUE #1713] [Issue]: Remote avatar endpoint only serves character avatars — persona and NPC avatars always 404 #851

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

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

Originally assigned to: @cha1latte on GitHub.

Summary

The /api/assets/avatar/ endpoint only serves avatars from avatars/characters/ but persona and NPC avatars are saved to different subdirectories that the endpoint never looks at. Files are written to locations they can never be served from.

Expected behavior

Persona and NPC avatars are served correctly via the remote asset endpoint when using a remote runtime, just like character avatars.

Actual behavior

  • Persona avatars are saved to avatars/personas/ but the endpoint only serves from avatars/characters/ → 404
  • NPC avatars are saved to avatars/npc/{chat_id}/{name} → endpoint rejects the subdirectory path entirely → 404
  • Not visibly broken in most cases due to base64 avatarPath fallback in the DB, but files are written to locations they can never be served from
  • Breaks completely for any character where avatarPath is not a base64 data URL (e.g. built-in characters referencing /sprites/...)

Steps to reproduce

  1. Run Marinara Engine as a remote HTTP backend
  2. Connect the Tauri desktop app via Settings → Remote Runtime URL
  3. Upload a new persona avatar or use a chat with NPC avatars
  4. Observe: avatar loads via base64 fallback (if present), file endpoint returns 404

To confirm directly:

curl -u user:pass http://<server>:8787/api/assets/avatar/<persona-avatar-filename>
# → 404, file is actually in avatars/personas/ not avatars/characters/

Environment

  • Marinara Engine version: Refactor
  • Install type: HTTP Docker Backend
  • OS + version: Linux server (Docker)

Additional context

Root cause is in http_server.rs — avatar_asset_path hardcodes avatars/characters/:

fn avatar_asset_path(state: &AppState, path: &str) -> Result<PathBuf, AppError> {
    let filename = avatar_asset_filename(path)?;
    Ok(state.data_dir.join("avatars").join("characters").join(filename))
}

But saves go to different locations depending on type:

  • Characters (persona_avatar_upload): avatars/personas/
  • NPCs (npc_avatar_upload): avatars/npc/{chat_id}/{name}

The NPC case is additionally broken because the path includes a subdirectory ({chat_id}) which avatar_asset_filename explicitly rejects (contains /).

Why it's not always visible: avatarPath in each record stores a base64 data URL as a fallback. The frontend falls back to this if the file endpoint fails. This masks the issue but means large base64 blobs are embedded in every API response instead of serving files efficiently.

Possible fixes:

  • Extend avatar_asset_path to accept a collection prefix and update the frontend to pass it in the URL (e.g. /api/assets/avatar/personas/{filename})
  • Or search across all avatar subdirectories as a fallback

Template check

  • I DID NOT read this template and provide the requested details.
Originally created by @Gunterlie on GitHub (May 31, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/1713 Originally assigned to: @cha1latte on GitHub. ## Summary The `/api/assets/avatar/` endpoint only serves avatars from `avatars/characters/` but persona and NPC avatars are saved to different subdirectories that the endpoint never looks at. Files are written to locations they can never be served from. ## Expected behavior Persona and NPC avatars are served correctly via the remote asset endpoint when using a remote runtime, just like character avatars. ## Actual behavior - Persona avatars are saved to `avatars/personas/` but the endpoint only serves from `avatars/characters/` → 404 - NPC avatars are saved to `avatars/npc/{chat_id}/{name}` → endpoint rejects the subdirectory path entirely → 404 - Not visibly broken in most cases due to base64 `avatarPath` fallback in the DB, but files are written to locations they can never be served from - Breaks completely for any character where `avatarPath` is not a base64 data URL (e.g. built-in characters referencing `/sprites/...`) ## Steps to reproduce 1. Run Marinara Engine as a remote HTTP backend 2. Connect the Tauri desktop app via Settings → Remote Runtime URL 3. Upload a new persona avatar or use a chat with NPC avatars 4. Observe: avatar loads via base64 fallback (if present), file endpoint returns 404 To confirm directly: ```bash curl -u user:pass http://<server>:8787/api/assets/avatar/<persona-avatar-filename> # → 404, file is actually in avatars/personas/ not avatars/characters/ ``` ## Environment - Marinara Engine version: Refactor - Install type: HTTP Docker Backend - OS + version: Linux server (Docker) ## Additional context Root cause is in `http_server.rs` — `avatar_asset_path` hardcodes `avatars/characters/`: ```rust fn avatar_asset_path(state: &AppState, path: &str) -> Result<PathBuf, AppError> { let filename = avatar_asset_filename(path)?; Ok(state.data_dir.join("avatars").join("characters").join(filename)) } ``` But saves go to different locations depending on type: - Characters (`persona_avatar_upload`): `avatars/personas/` - NPCs (`npc_avatar_upload`): `avatars/npc/{chat_id}/{name}` The NPC case is additionally broken because the path includes a subdirectory (`{chat_id}`) which `avatar_asset_filename` explicitly rejects (contains `/`). **Why it's not always visible:** `avatarPath` in each record stores a base64 data URL as a fallback. The frontend falls back to this if the file endpoint fails. This masks the issue but means large base64 blobs are embedded in every API response instead of serving files efficiently. **Possible fixes:** - Extend `avatar_asset_path` to accept a collection prefix and update the frontend to pass it in the URL (e.g. `/api/assets/avatar/personas/{filename}`) - Or search across all avatar subdirectories as a fallback ## Template check - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 05:22:07 +07:00
Author
Owner

@cha1latte commented on GitHub (May 31, 2026):

Fixed in #1741

<!-- gh-comment-id:4587866564 --> @cha1latte commented on GitHub (May 31, 2026): Fixed in #1741
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#851
No description provided.