RocketChat / RocketChat/Apps.QuickReplies

[Bug] Handle Gemini error responses safely in /quick ai

Open
#82 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
7
Forks
21
PR merge metrics
No merged PRs in 30d

Description

What happened?

Description

When /quick ai is used with Gemini and the provider returns an error payload instead of generated candidate text, the AI flow fails.

The current implementation assumes the Gemini response always contains text at:

response.data.candidates[0].content.parts[0].text

In practice, Gemini can return an error object instead of candidates, for example when the model is overloaded or temporarily unavailable. In those cases, /quick ai does not handle the response shape safely.

Expected behavior

  • /quick ai should safely handle Gemini responses that do not include candidates
  • if Gemini returns an explicit error payload, the app should surface the provider message instead of failing
  • if Gemini returns an unexpected shape without generated text, the app should log the error in gemini response.

Actual behaviour

  • /quick ai assumes the Gemini response always contains generated text at response.data.candidates[0].content.parts[0].text
  • when Gemini returns an error payload instead of candidates, the AI flow fails
  • proper logs are not generated
  • the modal falls back to a generic failure message instead of handling the provider response safely
Steps to reproduce
  1. Install the Quick Replies app
  2. Configure Gemini as the AI provider
  3. Trigger /quick ai
  4. Enter a prompt and click Generate
  5. Hit a Gemini error response such as overload / temporary unavailability
  6. Observe that the response does not contain generated candidate text
Relevant ScreenShots
Image
Version

v8.2.1

What browsers are you seeing the problem on?

Firefox

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the /quick ai entry point and trace the Gemini response handling around response.data.candidates[0].content.parts[0].text. Reproduce an overload or temporary-unavailability response, then verify that explicit provider messages are surfaced and unexpected responses are logged instead of causing a generic failure.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
backend-api-design
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.