[PR #825] [MERGED] Decode compressed provider responses #4793

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/825
Author: @Xelvanis
Created: 5/14/2026
Status: ✅ Merged
Merged: 5/14/2026
Merged by: @Xelvanis

Base: main ← Head: fix/provider-compressed-response-decoding


📝 Commits (3)

  • 221c914 fix(provider): decode compressed buffered responses
  • 072844b Make compressed response decoding opt-in in safeFetch
  • 2776d77 fix(provider): buffer compressed JSON response paths

📊 Changes

9 files changed (+284 additions, -24 deletions)

View changed files

📝 packages/server/src/routes/connections.routes.ts (+9 -0)
📝 packages/server/src/services/llm/base-provider.ts (+5 -2)
📝 packages/server/src/services/llm/openai-chatgpt-auth.ts (+2 -0)
📝 packages/server/src/services/llm/providers/anthropic.provider.ts (+1 -0)
📝 packages/server/src/utils/security.ts (+68 -20)
📝 packages/server/test/anthropic-provider-opus47.test.ts (+45 -0)
📝 packages/server/test/embedding-response.test.ts (+36 -0)
📝 packages/server/test/openai-provider-reasoning.test.ts (+44 -1)
📝 packages/server/test/security-utils.test.ts (+74 -1)

📄 Description

Linked issue

Follow-up to #781 and #784. No new GitHub issue exists yet for the Venice-specific report.

Why this change

  • A Venice API user reported that model fetching and the connection test message started returning garbled binary-looking text instead of readable JSON.
  • The previous provider response fix handled unlabeled raw gzip bytes, but Venice/Cloudflare can also return zstd-compressed provider responses.
  • When those bytes reach JSON parsing still compressed, Marinara surfaces unreadable text and fails before it can show the provider's actual response.

What changed

  • Added an opt-in compressed-response normalization path for buffered provider/API JSON fetches.
  • Decode raw gzip and zstd bodies when opted-in provider JSON responses arrive still compressed.
  • Strip stale content-encoding and content-length headers after normalization.
  • Opted in model-list/connection checks, OpenAI-compatible non-stream chat JSON, embeddings, Anthropic non-stream JSON, and ChatGPT auth/model JSON fetches.
  • Left general safeFetch consumers and streaming/SSE responses unchanged.
  • Added focused regression tests for raw gzip/zstd decoding, opt-in behavior, OpenAI-compatible non-stream chat, embeddings, and Anthropic non-stream chat.

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

  • Ran pnpm --filter @marinara-engine/server exec tsx --import ./test/setup-env.ts --test test/security-utils.test.ts test/openai-provider-reasoning.test.ts test/connections-horde-routes.test.ts test/embedding-response.test.ts test/anthropic-provider-opus47.test.ts; passed.
  • Ran pnpm check; passed.
  • Live unauthenticated probe of Venice /models confirmed Venice/Cloudflare can return content-encoding: zstd when the client advertises zstd support.
  • Not run: live authenticated Venice chat/test-message verification with a real API key.
  • Not run: Docker/Podman container verification.

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 expected; this is a narrow server/provider response decoding fix.

UI evidence (if applicable)

N/A. Server/provider response decoding only.


🔄 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/825 **Author:** [@Xelvanis](https://github.com/Xelvanis) **Created:** 5/14/2026 **Status:** ✅ Merged **Merged:** 5/14/2026 **Merged by:** [@Xelvanis](https://github.com/Xelvanis) **Base:** `main` ← **Head:** `fix/provider-compressed-response-decoding` --- ### 📝 Commits (3) - [`221c914`](https://github.com/Pasta-Devs/Marinara-Engine/commit/221c9145d1c743da88d3f3067bf59f713cc9167d) fix(provider): decode compressed buffered responses - [`072844b`](https://github.com/Pasta-Devs/Marinara-Engine/commit/072844b1301ec046878632f1ef5331963caec762) Make compressed response decoding opt-in in safeFetch - [`2776d77`](https://github.com/Pasta-Devs/Marinara-Engine/commit/2776d778c3569dce7bf327d08443e52ce441ac78) fix(provider): buffer compressed JSON response paths ### 📊 Changes **9 files changed** (+284 additions, -24 deletions) <details> <summary>View changed files</summary> 📝 `packages/server/src/routes/connections.routes.ts` (+9 -0) 📝 `packages/server/src/services/llm/base-provider.ts` (+5 -2) 📝 `packages/server/src/services/llm/openai-chatgpt-auth.ts` (+2 -0) 📝 `packages/server/src/services/llm/providers/anthropic.provider.ts` (+1 -0) 📝 `packages/server/src/utils/security.ts` (+68 -20) 📝 `packages/server/test/anthropic-provider-opus47.test.ts` (+45 -0) 📝 `packages/server/test/embedding-response.test.ts` (+36 -0) 📝 `packages/server/test/openai-provider-reasoning.test.ts` (+44 -1) 📝 `packages/server/test/security-utils.test.ts` (+74 -1) </details> ### 📄 Description ## Linked issue Follow-up to #781 and #784. No new GitHub issue exists yet for the Venice-specific report. ## Why this change - A Venice API user reported that model fetching and the connection test message started returning garbled binary-looking text instead of readable JSON. - The previous provider response fix handled unlabeled raw gzip bytes, but Venice/Cloudflare can also return zstd-compressed provider responses. - When those bytes reach JSON parsing still compressed, Marinara surfaces unreadable text and fails before it can show the provider's actual response. ## What changed - Added an opt-in compressed-response normalization path for buffered provider/API JSON fetches. - Decode raw gzip and zstd bodies when opted-in provider JSON responses arrive still compressed. - Strip stale `content-encoding` and `content-length` headers after normalization. - Opted in model-list/connection checks, OpenAI-compatible non-stream chat JSON, embeddings, Anthropic non-stream JSON, and ChatGPT auth/model JSON fetches. - Left general `safeFetch` consumers and streaming/SSE responses unchanged. - Added focused regression tests for raw gzip/zstd decoding, opt-in behavior, OpenAI-compatible non-stream chat, embeddings, and Anthropic non-stream chat. ## Validation - [x] `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) - [x] Above manual verification completed (describe below) - [x] Read and followed `CONTRIBUTING.md` ### Manual verification notes - Ran `pnpm --filter @marinara-engine/server exec tsx --import ./test/setup-env.ts --test test/security-utils.test.ts test/openai-provider-reasoning.test.ts test/connections-horde-routes.test.ts test/embedding-response.test.ts test/anthropic-provider-opus47.test.ts`; passed. - Ran `pnpm check`; passed. - Live unauthenticated probe of Venice `/models` confirmed Venice/Cloudflare can return `content-encoding: zstd` when the client advertises zstd support. - Not run: live authenticated Venice chat/test-message verification with a real API key. - Not run: Docker/Podman container verification. ## Docs and release impact - [x] 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 expected; this is a narrow server/provider response decoding fix. ## UI evidence (if applicable) N/A. Server/provider response decoding only. --- <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:42 +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#4793
No description provided.