[GH-ISSUE #2434] [Issue]: 11-PROV-PERF-timeouts-size-streaming TTS audio cap is checked after buffering #1189

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

Originally created by @Promansis on GitHub (Jun 6, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2434

Originally assigned to: @SpicyMarinara on GitHub.

Summary

11-PROV-PERF-timeouts-size-streaming: Rust TTS transport checks the 20 MiB audio cap only after response.bytes() buffers the whole provider response.

Links back to #2410.

Expected behavior

Provider TTS audio responses should be bounded while reading, so oversized audio cannot be fully buffered before rejection.

Acceptance criteria:

  • TTS speech response reading enforces MAX_TTS_AUDIO_BYTES during the read, including chunked responses without trusted Content-Length.
  • Oversized TTS audio returns a precise error.
  • Existing content-type and provider-error behavior remains intact.
  • Add focused mocked-provider proof for an oversized/chunked audio response.

Actual behavior

Refactor Rust TTS sets a request timeout and has MAX_TTS_AUDIO_BYTES, but reads the complete provider body with response.bytes().await before checking bytes.len() > MAX_TTS_AUDIO_BYTES.

Steps to reproduce

  1. Inspect src-tauri/src/commands/storage/integrations/tts.rs.
  2. Follow speak through provider request send.
  3. Observe the response body is read with response.bytes().await before the size check.

Impact area

  • App shell, navigation, startup, or providers
  • Catalog resources
  • Chat mode
  • Roleplay mode
  • Game mode
  • Shared mode UI
  • Runtime systems: generation, world-state, visuals, tracker, or haptics
  • Professor Mari or shell tools
  • React-free engine behavior, contracts, agents, or capability ports
  • Shared API wrapper or remote runtime routing
  • Tauri/Rust storage, assets, LLM, integrations, security, imports, or HTTP runtime
  • Docs, contributor workflow, or templates

Environment

  • Branch or commit: refactor@09923989
  • Run mode: Tauri desktop / remote runtime
  • OS + version: not relevant
  • Node + pnpm versions: not relevant
  • Rust version, if relevant: not checked
  • Remote Runtime URL configured? not relevant
  • Provider, model, or integration, if relevant: TTS providers

Logs, screenshots, or video

Static trace proof only. No live provider call was run.

Regression notes

Legacy main used TTS safeFetch with maxResponseBytes: MAX_TTS_AUDIO_BYTES, so the response cap was enforced by the fetch wrapper.

Refactor evidence:

  • src-tauri/src/commands/storage/integrations/tts.rs:8 defines MAX_TTS_AUDIO_BYTES.
  • src-tauri/src/commands/storage/integrations/tts.rs:355 sets the provider request timeout.
  • src-tauri/src/commands/storage/integrations/tts.rs:425 reads the entire response body.
  • src-tauri/src/commands/storage/integrations/tts.rs:445 checks the cap after buffering.

Legacy evidence:

  • packages/server/src/routes/tts.routes.ts:99 defines MAX_TTS_AUDIO_BYTES.
  • packages/server/src/routes/tts.routes.ts:670 sets a TTS provider timeout.
  • packages/server/src/routes/tts.routes.ts:676 passes maxResponseBytes: MAX_TTS_AUDIO_BYTES.

Additional context

Surface ID: 11-PROV-PERF-timeouts-size-streaming.

Template check

Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @Promansis on GitHub (Jun 6, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2434 Originally assigned to: @SpicyMarinara on GitHub. ## Summary `11-PROV-PERF-timeouts-size-streaming`: Rust TTS transport checks the 20 MiB audio cap only after `response.bytes()` buffers the whole provider response. Links back to #2410. ## Expected behavior Provider TTS audio responses should be bounded while reading, so oversized audio cannot be fully buffered before rejection. Acceptance criteria: - TTS speech response reading enforces `MAX_TTS_AUDIO_BYTES` during the read, including chunked responses without trusted `Content-Length`. - Oversized TTS audio returns a precise error. - Existing content-type and provider-error behavior remains intact. - Add focused mocked-provider proof for an oversized/chunked audio response. ## Actual behavior Refactor Rust TTS sets a request timeout and has `MAX_TTS_AUDIO_BYTES`, but reads the complete provider body with `response.bytes().await` before checking `bytes.len() > MAX_TTS_AUDIO_BYTES`. ## Steps to reproduce 1. Inspect `src-tauri/src/commands/storage/integrations/tts.rs`. 2. Follow `speak` through provider request send. 3. Observe the response body is read with `response.bytes().await` before the size check. ## Impact area - [ ] App shell, navigation, startup, or providers - [ ] Catalog resources - [ ] Chat mode - [ ] Roleplay mode - [ ] Game mode - [ ] Shared mode UI - [ ] Runtime systems: generation, world-state, visuals, tracker, or haptics - [ ] Professor Mari or shell tools - [ ] React-free engine behavior, contracts, agents, or capability ports - [ ] Shared API wrapper or remote runtime routing - [x] Tauri/Rust storage, assets, LLM, integrations, security, imports, or HTTP runtime - [ ] Docs, contributor workflow, or templates ## Environment - Branch or commit: refactor@09923989 - Run mode: Tauri desktop / remote runtime - OS + version: not relevant - Node + pnpm versions: not relevant - Rust version, if relevant: not checked - Remote Runtime URL configured? not relevant - Provider, model, or integration, if relevant: TTS providers ## Logs, screenshots, or video Static trace proof only. No live provider call was run. ## Regression notes Legacy `main` used TTS `safeFetch` with `maxResponseBytes: MAX_TTS_AUDIO_BYTES`, so the response cap was enforced by the fetch wrapper. Refactor evidence: - `src-tauri/src/commands/storage/integrations/tts.rs:8` defines `MAX_TTS_AUDIO_BYTES`. - `src-tauri/src/commands/storage/integrations/tts.rs:355` sets the provider request timeout. - `src-tauri/src/commands/storage/integrations/tts.rs:425` reads the entire response body. - `src-tauri/src/commands/storage/integrations/tts.rs:445` checks the cap after buffering. Legacy evidence: - `packages/server/src/routes/tts.routes.ts:99` defines `MAX_TTS_AUDIO_BYTES`. - `packages/server/src/routes/tts.routes.ts:670` sets a TTS provider timeout. - `packages/server/src/routes/tts.routes.ts:676` passes `maxResponseBytes: MAX_TTS_AUDIO_BYTES`. ## Additional context Surface ID: `11-PROV-PERF-timeouts-size-streaming`. ## Template check Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 05:28:33 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@SpicyMarinara commented on GitHub (Jun 6, 2026):

Closed on refactor with implementation in 1650f9a3 and focused proof in 1e2a1a11.

What changed:

  • The current TTS path already reads provider audio through read_capped_audio_bytes, which checks Content-Length before download and enforces MAX_TTS_AUDIO_BYTES while streaming chunks.
  • Added mocked PocketTTS proof for a chunked audio response over the cap, confirming it returns the precise too-large error without accepting the oversized body.

Verification:

  • cargo check --manifest-path src-tauri/Cargo.toml --workspace
  • cargo test --manifest-path src-tauri/Cargo.toml -p marinara-engine tts_speak_rejects_chunked_audio_over_cap -- --nocapture
  • cargo test --manifest-path src-tauri/Cargo.toml -p marinara-engine tts -- --nocapture
  • pnpm check:architecture
<!-- gh-comment-id:4638160665 --> @SpicyMarinara commented on GitHub (Jun 6, 2026): Closed on refactor with implementation in 1650f9a3 and focused proof in 1e2a1a11. What changed: - The current TTS path already reads provider audio through read_capped_audio_bytes, which checks Content-Length before download and enforces MAX_TTS_AUDIO_BYTES while streaming chunks. - Added mocked PocketTTS proof for a chunked audio response over the cap, confirming it returns the precise too-large error without accepting the oversized body. Verification: - cargo check --manifest-path src-tauri/Cargo.toml --workspace - cargo test --manifest-path src-tauri/Cargo.toml -p marinara-engine tts_speak_rejects_chunked_audio_over_cap -- --nocapture - cargo test --manifest-path src-tauri/Cargo.toml -p marinara-engine tts -- --nocapture - pnpm check:architecture
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#1189
No description provided.