[PR #704] [MERGED] Fix Pygmalion avatar content type fallback #4734

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

📋 Pull Request Information

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

Base: main ← Head: fix/issue-687-pygmalion-content-type


📝 Commits (1)

  • 0832f80 Fix Pygmalion avatar content type fallback

📊 Changes

1 file changed (+12 additions, -3 deletions)

View changed files

📝 packages/server/src/routes/bot-browser-pygmalion.routes.ts (+12 -3)

📄 Description

Linked issue

Closes #687

Why this change

  • Pygmalion avatar proxy requests could return HTTP 500 when the upstream image response omitted Content-Type, which surfaced while browsing/logging into Pygmalion after the security hardening switched the avatar path to safeFetch.

What changed

  • Keeps Pygmalion avatar proxy requests on safeFetch for outbound URL policy and byte caps.
  • Validates buffered avatar responses with image magic bytes when Content-Type is missing.
  • Rejects non-image responses with HTTP 415 instead of proxying them or throwing a generic 500.

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 original route failure with pnpm --filter @marinara-engine/server exec tsx ../../scratch/issue-687-pygmalion-avatar-repro.mjs missing-content-type: before the fix, a valid PNG avatar response without Content-Type returned HTTP 500.
  • Codex re-ran the same repro after the fix: the missing-content-type valid PNG case returned HTTP 200 with image/png.
  • Codex checked adjacent cases: a normal image/png response still returned HTTP 200, and a text/plain non-image response returned HTTP 415.
  • Codex ran pnpm check; it passed impeccable:check, lint, and production build.
  • No human-only verification blockers remain for the route-level core claim. A real Pygmalion account/token smoke test is still useful before release if someone has a current token handy.

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 bug fix.

UI evidence (if applicable)

N/A: backend route bug. Route-level proof:

{
  "beforeFixMissingContentType": { "statusCode": 500, "contentType": "application/json; charset=utf-8" },
  "afterFixMissingContentType": { "statusCode": 200, "contentType": "image/png" },
  "afterFixNormalImageContentType": { "statusCode": 200, "contentType": "image/png" },
  "afterFixTextResponse": { "statusCode": 415, "bodyPreview": "{\"error\":\"Unsupported avatar content type\"}" }
}

🔄 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/704 **Author:** [@cha1latte](https://github.com/cha1latte) **Created:** 5/11/2026 **Status:** ✅ Merged **Merged:** 5/11/2026 **Merged by:** [@cha1latte](https://github.com/cha1latte) **Base:** `main` ← **Head:** `fix/issue-687-pygmalion-content-type` --- ### 📝 Commits (1) - [`0832f80`](https://github.com/Pasta-Devs/Marinara-Engine/commit/0832f8009eb0dc92243414d72e11e5dea3e7f225) Fix Pygmalion avatar content type fallback ### 📊 Changes **1 file changed** (+12 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `packages/server/src/routes/bot-browser-pygmalion.routes.ts` (+12 -3) </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 #687 ## Why this change <!-- What user problem, bug, or goal does this solve? --> - Pygmalion avatar proxy requests could return HTTP 500 when the upstream image response omitted `Content-Type`, which surfaced while browsing/logging into Pygmalion after the security hardening switched the avatar path to `safeFetch`. ## What changed <!-- List the key changes in this PR --> - Keeps Pygmalion avatar proxy requests on `safeFetch` for outbound URL policy and byte caps. - Validates buffered avatar responses with image magic bytes when `Content-Type` is missing. - Rejects non-image responses with HTTP 415 instead of proxying them or throwing a generic 500. ## 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 original route failure with `pnpm --filter @marinara-engine/server exec tsx ../../scratch/issue-687-pygmalion-avatar-repro.mjs missing-content-type`: before the fix, a valid PNG avatar response without `Content-Type` returned HTTP 500. - Codex re-ran the same repro after the fix: the missing-content-type valid PNG case returned HTTP 200 with `image/png`. - Codex checked adjacent cases: a normal `image/png` response still returned HTTP 200, and a `text/plain` non-image response returned HTTP 415. - Codex ran `pnpm check`; it passed `impeccable:check`, lint, and production build. - No human-only verification blockers remain for the route-level core claim. A real Pygmalion account/token smoke test is still useful before release if someone has a current token handy. ## 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 bug fix. ## UI evidence (if applicable) N/A: backend route bug. Route-level proof: ```json { "beforeFixMissingContentType": { "statusCode": 500, "contentType": "application/json; charset=utf-8" }, "afterFixMissingContentType": { "statusCode": 200, "contentType": "image/png" }, "afterFixNormalImageContentType": { "statusCode": 200, "contentType": "image/png" }, "afterFixTextResponse": { "statusCode": 415, "bodyPreview": "{\"error\":\"Unsupported avatar content type\"}" } } ``` --- <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:12 +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#4734
No description provided.