[GH-ISSUE #3660] [Issue]: safeFetch rejects missing Content-Type and doesn't decompress gzip JSON responses #1979

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

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

Originally assigned to: @SpicyMarinara on GitHub.

Summary

safeFetch rejects responses with a missing Content-Type header and fails to decompress gzip-encoded JSON responses, causing card browser API calls and the capability package catalog to fail on every server start.

Expected behavior

Card browser JSON endpoints and the capability package catalog load successfully regardless of whether the upstream server omits Content-Type or returns a gzip-compressed response body.

Actual behavior

Server logs "Outbound response content type is not allowed: " (empty string) for any response missing a Content-Type header. After fixing that, gzip responses from GitHub raw content and card browser APIs cause response.json() to throw SyntaxError: Unexpected token '\u001f' because readCappedResponse reads the raw byte stream directly, bypassing undici's built-in Content-Encoding decompression.

Steps to reproduce

  1. Start the server
  2. Observe "Optional package availability migration did not complete" warning in server log
  3. Open card browser → ChubAI tab
  4. Observe Outbound response content type is not allowed: and/or SyntaxError: Unexpected token '\u001f' in server log

Environment

  • Marinara Engine version: 2.3.1
  • Install type: source
  • OS + version: Linux (reproduced), likely affects all platforms
  • Browser or app shell: any

Logs, screenshots, or video

{"err":{"message":"Outbound response content type is not allowed: "},"msg":"Optional package availability migration did not complete; it will retry next startup"}
{"err":{"message":"Unexpected token '\u001f', "\u001f\x8b\x08\x00..." is not valid JSON"},"msg":"Unexpected token..."}

Additional context

safeFetch's allowedContentTypes guard uses !contentType || which should be contentType && — same || bug fixed in the avatar image proxy paths. The gzip issue is separate: readCappedResponse uses response.body.getReader() directly which bypasses undici decompression; decodeCompressedResponse: true is the existing opt-in fix.

Template check

  • I DID NOT read this template and provide the requested details.
Originally created by @Lamboozled on GitHub (Jul 15, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/3660 Originally assigned to: @SpicyMarinara on GitHub. ## Summary `safeFetch` rejects responses with a missing `Content-Type` header and fails to decompress gzip-encoded JSON responses, causing card browser API calls and the capability package catalog to fail on every server start. ## Expected behavior Card browser JSON endpoints and the capability package catalog load successfully regardless of whether the upstream server omits `Content-Type` or returns a gzip-compressed response body. ## Actual behavior Server logs "Outbound response content type is not allowed: " (empty string) for any response missing a `Content-Type` header. After fixing that, gzip responses from GitHub raw content and card browser APIs cause `response.json()` to throw `SyntaxError: Unexpected token '\u001f'` because `readCappedResponse` reads the raw byte stream directly, bypassing undici's built-in `Content-Encoding` decompression. ## Steps to reproduce 1. Start the server 2. Observe "Optional package availability migration did not complete" warning in server log 3. Open card browser → ChubAI tab 4. Observe `Outbound response content type is not allowed:` and/or `SyntaxError: Unexpected token '\u001f'` in server log ## Environment - Marinara Engine version: 2.3.1 - Install type: source - OS + version: Linux (reproduced), likely affects all platforms - Browser or app shell: any ## Logs, screenshots, or video {"err":{"message":"Outbound response content type is not allowed: "},"msg":"Optional package availability migration did not complete; it will retry next startup"} {"err":{"message":"Unexpected token '\u001f', "\u001f\x8b\x08\x00..." is not valid JSON"},"msg":"Unexpected token..."} ## Additional context `safeFetch`'s `allowedContentTypes` guard uses `!contentType ||` which should be `contentType &&` — same `||` bug fixed in the avatar image proxy paths. The gzip issue is separate: `readCappedResponse` uses `response.body.getReader()` directly which bypasses undici decompression; `decodeCompressedResponse: true` is the existing opt-in fix. ## Template check - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 05:44:19 +07:00
  • closed this issue
  • added the
    in-pr
    bug
    labels
Author
Owner

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

Thank you for the PR, checking it our right now!

<!-- gh-comment-id:4986194265 --> @SpicyMarinara commented on GitHub (Jul 15, 2026): Thank you for the PR, checking it our right now!
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#1979
No description provided.