[PR #836] [MERGED] Request identity encoding for provider responses #4799

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

📋 Pull Request Information

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

Base: main ← Head: fix/provider-stream-identity-encoding


📝 Commits (3)

  • b69bd23 fix(provider): request identity encoding for LLM streams
  • 816e3a2 fix(provider): request identity encoding for provider JSON
  • 607aede refactor(provider): share identity encoding header helper

📊 Changes

4 files changed (+82 additions, -1 deletions)

View changed files

📝 packages/server/src/services/llm/base-provider.ts (+2 -1)
📝 packages/server/src/utils/security.ts (+11 -0)
📝 packages/server/test/openai-provider-reasoning.test.ts (+44 -0)
📝 packages/server/test/security-utils.test.ts (+25 -0)

📄 Description

Linked issue

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

Why this change

  • After #834, the user no longer showed compressed JSON parse errors but still got an empty model response from generation.
  • A direct Venice probe showed the models endpoint returns plain JSON with Accept-Encoding: identity, but returns zstd-compressed bytes when broader encodings are advertised.
  • That means the safest follow-up is to ask the provider/proxy for identity encoding on both LLM streams and opted-in provider JSON fetches, instead of depending on every runtime/proxy path to decode the same way.

What changed

  • LLM provider requests now default Accept-Encoding to identity.
  • Buffered provider/API JSON fetches that opt into compressed-response normalization now also default Accept-Encoding to identity.
  • Explicit caller-provided accept-encoding headers are preserved.
  • Added regression coverage for OpenAI-compatible streaming chatComplete() and opted-in safeFetch provider JSON requests.

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 with the existing Node DEP0190 warning during the server build.
  • Not run: live authenticated Venice streaming chat 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 request negotiation fix.

UI evidence (if applicable)

N/A. Server/provider request handling only.

Summary by CodeRabbit

  • Improvements

    • Enhanced request header management for LLM and security-related fetch operations to ensure proper and consistent encoding handling across all outgoing server requests.
  • Tests

    • Added test coverage to verify correct request header encoding in LLM streaming requests and security utility functions, ensuring expected behavior is maintained.

Review Change Stack


🔄 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/836 **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-stream-identity-encoding` --- ### 📝 Commits (3) - [`b69bd23`](https://github.com/Pasta-Devs/Marinara-Engine/commit/b69bd23ebb3ae18107114e066987d9cf49c98edd) fix(provider): request identity encoding for LLM streams - [`816e3a2`](https://github.com/Pasta-Devs/Marinara-Engine/commit/816e3a26c74f0dee5162ef3a154b29368dcb892e) fix(provider): request identity encoding for provider JSON - [`607aede`](https://github.com/Pasta-Devs/Marinara-Engine/commit/607aedebab250ff8ea161319f54b1b9d459bed5d) refactor(provider): share identity encoding header helper ### 📊 Changes **4 files changed** (+82 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `packages/server/src/services/llm/base-provider.ts` (+2 -1) 📝 `packages/server/src/utils/security.ts` (+11 -0) 📝 `packages/server/test/openai-provider-reasoning.test.ts` (+44 -0) 📝 `packages/server/test/security-utils.test.ts` (+25 -0) </details> ### 📄 Description ## Linked issue Follow-up to #825 and #834. No new GitHub issue exists yet for the Venice-specific follow-up report. ## Why this change - After #834, the user no longer showed compressed JSON parse errors but still got an empty model response from generation. - A direct Venice probe showed the models endpoint returns plain JSON with `Accept-Encoding: identity`, but returns zstd-compressed bytes when broader encodings are advertised. - That means the safest follow-up is to ask the provider/proxy for identity encoding on both LLM streams and opted-in provider JSON fetches, instead of depending on every runtime/proxy path to decode the same way. ## What changed - LLM provider requests now default `Accept-Encoding` to `identity`. - Buffered provider/API JSON fetches that opt into compressed-response normalization now also default `Accept-Encoding` to `identity`. - Explicit caller-provided `accept-encoding` headers are preserved. - Added regression coverage for OpenAI-compatible streaming `chatComplete()` and opted-in `safeFetch` provider JSON requests. ## 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) - [ ] 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`; passed. - Ran `pnpm check`; passed with the existing Node `DEP0190` warning during the server build. - Not run: live authenticated Venice streaming chat 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 request negotiation fix. ## UI evidence (if applicable) N/A. Server/provider request handling only. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Improvements** * Enhanced request header management for LLM and security-related fetch operations to ensure proper and consistent encoding handling across all outgoing server requests. * **Tests** * Added test coverage to verify correct request header encoding in LLM streaming requests and security utility functions, ensuring expected behavior is maintained. <!-- review_stack_entry_start --> [![Review Change Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/Pasta-Devs/Marinara-Engine/pull/836) <!-- review_stack_entry_end --> <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <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:45 +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#4799
No description provided.