mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2666] [Issue]: Gemini streaming swallows mid-stream error / promptFeedback.blockReason → silent truncated output #1317
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#1317
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @kolacheee on GitHub (Jun 20, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2666
Originally assigned to: @SpicyMarinara on GitHub.
Summary
During a Gemini stream, mid-stream
errorobjects andpromptFeedback.blockReasonnotices are valid JSON, so they bypass the malformed-linecatch, are not recognized by the parser, and are silently dropped — the stream ends with truncated/empty output and no error surfaced.Expected behavior
A mid-stream Gemini error or safety block should abort generation and surface a clear error the user can see and retry, not return partial/empty text as success.
Actual behavior
The streaming loop only reads
parsed.usageMetadataandparsed.candidates?.[0]?.content?.parts. A{"error":{...}}or{"promptFeedback":{"blockReason":"SAFETY"}}line parses cleanly (so the// Skip malformed linescatch never fires), matches neither branch, yields emptyparts, and is ignored; the generator then ends normally.How it breaks the pipeline
Code trace (staging @
b826f8f4) —packages/server/src/services/llm/providers/google.provider.ts::664–691;JSON.parse~:665; onlyusageMetadata(:666) andcandidates[0].content.parts(:674) are read;catch { // Skip malformed lines }at ~:690.errororpromptFeedback/blockReasonanywhere in the file (confirmed by search), so neither is handled.This is the Google analog of the already-filed Anthropic mid-stream error swallow (#2659), which is scoped to
anthropic.provider.tsonly — so it is a distinct, unfiled bug.Steps to reproduce
data: {"error":{"code":429,...}}mid-stream (rate limit), or a prompt that trips a mid-streamSAFETYblock after the initial 200 OK.chat()returns normally with partial/empty text; no error is logged or surfaced.Suggested fix
Inside the streaming
tryblock, afterJSON.parse, inspect the object before extractingparts: ifparsed.erroris present, throw a sanitizedGemini API streaming error: ...; ifparsed.promptFeedback?.blockReasonis set, throw an error naming the block reason.Environment
b826f8f4)Additional context
Identified via systematic source review on staging (refs @
b826f8f4). Closely related to the "blocked/empty Gemini response reported as normal stop" issue filed concurrently; both stem from the Gemini handlers not inspectingpromptFeedback/error/finishReason.Template check
Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:
@SpicyMarinara commented on GitHub (Jun 20, 2026):
Implemented on branch codex/spicymarinara-assigned-issues: Gemini streaming now aborts on streamed error objects and promptFeedback.blockReason. Final validation will run after the full assigned sweep per maintainer request.