[PR #612] [MERGED] Fix GoogleProvider empty candidate scene summary crash #4695

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/612
Author: @cha1latte
Created: 5/9/2026
Status: ✅ Merged
Merged: 5/9/2026
Merged by: @cha1latte

Base: main ← Head: fix/issue-600-google-provider-empty-candidate


📝 Commits (1)

  • 4ac8045 Fix Google provider empty candidate handling

📊 Changes

1 file changed (+2 additions, -2 deletions)

View changed files

📝 packages/server/src/services/llm/providers/google.provider.ts (+2 -2)

📄 Description

Linked issue

Closes #600

Why this change

  • Scene summary wrap-up can fail for GoogleProvider connections when Google returns a successful response without a usable candidates array. The provider then throws Cannot read properties of undefined (reading '0'), which bubbles up as a 502 during scene conclusion instead of returning a normal empty-response error.

What changed

  • Treat Google non-streaming candidates as optional before reading the first candidate's parts.
  • Preserve the existing behavior where an empty provider response produces empty content for the scene route to handle.

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

  • Codex reproduced the crash before the fix with pnpm --filter @marinara-engine/server exec tsx ../../scratch/issue-600-google-empty-candidates-repro.ts: missing candidates: FAIL and TypeError: Cannot read properties of undefined (reading '0').
  • Codex re-ran the same scratch repro after the fix. It passed for a missing candidates field, an empty candidates array, and a normal text candidate.
  • Codex ran pnpm check; it passed impeccable:check, lint, and shared/server/client build.
  • Manual Docker-lite verification with a real GoogleProvider key was not performed in this environment. The patched provider path was exercised locally with a Gemini-compatible mock endpoint.

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)

UI evidence (if applicable)

N/A. This is a backend provider response-shape fix with no visible UI surface change.

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of edge cases in AI model response parsing to ensure stability when API responses lack expected data structures, preventing potential runtime errors.

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/612 **Author:** [@cha1latte](https://github.com/cha1latte) **Created:** 5/9/2026 **Status:** ✅ Merged **Merged:** 5/9/2026 **Merged by:** [@cha1latte](https://github.com/cha1latte) **Base:** `main` ← **Head:** `fix/issue-600-google-provider-empty-candidate` --- ### 📝 Commits (1) - [`4ac8045`](https://github.com/Pasta-Devs/Marinara-Engine/commit/4ac8045c172b150a8f1cb501c300b660aa93c6dc) Fix Google provider empty candidate handling ### 📊 Changes **1 file changed** (+2 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `packages/server/src/services/llm/providers/google.provider.ts` (+2 -2) </details> ### 📄 Description ## Linked issue <!-- Every PR should reference a feature request or issue report. If there isn't one yet, open one first to gather opinions: --> <!-- https://github.com/Pasta-Devs/Marinara-Engine/issues/new/choose --> Closes #600 ## Why this change <!-- What user problem, bug, or goal does this solve? --> - Scene summary wrap-up can fail for GoogleProvider connections when Google returns a successful response without a usable `candidates` array. The provider then throws `Cannot read properties of undefined (reading '0')`, which bubbles up as a 502 during scene conclusion instead of returning a normal empty-response error. ## What changed <!-- List the key changes in this PR --> - Treat Google non-streaming `candidates` as optional before reading the first candidate's parts. - Preserve the existing behavior where an empty provider response produces empty content for the scene route to handle. ## Validation <!-- Required: include commands run and/or manual checks performed --> - [ ] `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 <!-- Describe exactly what you tested in a real browser/app, step by step. --> <!-- ⚠️ If an AI agent filled out or ticked these boxes for you, treat them --> <!-- as a TO-DO LIST, not as proof the work is done. Verify each item yourself --> <!-- before submitting. If you haven't verified it, untick the box. --> - Codex reproduced the crash before the fix with `pnpm --filter @marinara-engine/server exec tsx ../../scratch/issue-600-google-empty-candidates-repro.ts`: `missing candidates: FAIL` and `TypeError: Cannot read properties of undefined (reading '0')`. - Codex re-ran the same scratch repro after the fix. It passed for a missing `candidates` field, an empty `candidates` array, and a normal text candidate. - Codex ran `pnpm check`; it passed `impeccable:check`, lint, and shared/server/client build. - Manual Docker-lite verification with a real GoogleProvider key was not performed in this environment. The patched provider path was exercised locally with a Gemini-compatible mock endpoint. ## 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) ## UI evidence (if applicable) N/A. This is a backend provider response-shape fix with no visible UI surface change. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved handling of edge cases in AI model response parsing to ensure stability when API responses lack expected data structures, preventing potential runtime errors. [![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/612) <!-- 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:09:53 +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#4695
No description provided.