[PR #834] [MERGED] Decode brotli provider JSON responses #4796

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

📋 Pull Request Information

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

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


📝 Commits (1)

  • 06c6029 fix(provider): decode brotli provider JSON responses

📊 Changes

3 files changed (+59 additions, -6 deletions)

View changed files

📝 packages/server/src/utils/security.ts (+15 -2)
📝 packages/server/test/openai-provider-reasoning.test.ts (+41 -1)
📝 packages/server/test/security-utils.test.ts (+3 -3)

📄 Description

Linked issue

Follow-up to #825. No new GitHub issue exists yet for the Venice-specific follow-up report.

Why this change

  • A Venice API user still received compressed-looking bytes after #825, now in an OpenAI-compatible non-stream chatComplete() response during conversation summary generation.
  • The failing body preview starts with bytes that match raw brotli output rather than gzip or zstd.
  • #825 intentionally narrowed fallback decoding to gzip/zstd, so raw brotli provider JSON could still reach JSON parsing and fail.
  • After the brotli fallback, the remaining empty-response report no longer showed JSON parse errors, which points at streaming responses still being compressed before the SSE parser sees them.

What changed

  • Added brotli as a narrow fallback in the existing opt-in buffered provider JSON normalization path.
  • Only accepts a brotli decode when the decoded body looks like provider JSON or SSE text.
  • LLM provider requests now default Accept-Encoding to identity, while still preserving any explicit caller-provided encoding header.
  • Added regression coverage for OpenAI-compatible non-stream chatComplete() receiving raw brotli JSON.
  • Extended the shared compressed-body decoder test to cover gzip, brotli, and zstd JSON.
  • Added coverage that streaming LLM requests ask providers for identity encoding.

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; passed.
  • Ran pnpm check; passed.
  • 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 follow-up.

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/834 **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-brotli-response-decoding` --- ### 📝 Commits (1) - [`06c6029`](https://github.com/Pasta-Devs/Marinara-Engine/commit/06c60294c54000a9d0335ffd5f8b21dd94719d80) fix(provider): decode brotli provider JSON responses ### 📊 Changes **3 files changed** (+59 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `packages/server/src/utils/security.ts` (+15 -2) 📝 `packages/server/test/openai-provider-reasoning.test.ts` (+41 -1) 📝 `packages/server/test/security-utils.test.ts` (+3 -3) </details> ### 📄 Description ## Linked issue Follow-up to #825. No new GitHub issue exists yet for the Venice-specific follow-up report. ## Why this change - A Venice API user still received compressed-looking bytes after #825, now in an OpenAI-compatible non-stream `chatComplete()` response during conversation summary generation. - The failing body preview starts with bytes that match raw brotli output rather than gzip or zstd. - #825 intentionally narrowed fallback decoding to gzip/zstd, so raw brotli provider JSON could still reach JSON parsing and fail. - After the brotli fallback, the remaining empty-response report no longer showed JSON parse errors, which points at streaming responses still being compressed before the SSE parser sees them. ## What changed - Added brotli as a narrow fallback in the existing opt-in buffered provider JSON normalization path. - Only accepts a brotli decode when the decoded body looks like provider JSON or SSE text. - LLM provider requests now default `Accept-Encoding` to `identity`, while still preserving any explicit caller-provided encoding header. - Added regression coverage for OpenAI-compatible non-stream `chatComplete()` receiving raw brotli JSON. - Extended the shared compressed-body decoder test to cover gzip, brotli, and zstd JSON. - Added coverage that streaming LLM requests ask providers for identity encoding. ## 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`; passed. - Ran `pnpm check`; passed. - 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 follow-up. ## 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:44 +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#4796
No description provided.