Skip to content

fix: handle Gemini error responses in quick ai#83

Open
CodeMatrix1 wants to merge 1 commit intoRocketChat:mainfrom
CodeMatrix1:fix/gemini-ai-error-responses
Open

fix: handle Gemini error responses in quick ai#83
CodeMatrix1 wants to merge 1 commit intoRocketChat:mainfrom
CodeMatrix1:fix/gemini-ai-error-responses

Conversation

@CodeMatrix1
Copy link
Copy Markdown

Issue(s)

Related to Gemini failures in /quick ai when the API returns an error payload instead of generated candidate text.
fixes #82

Acceptance Criteria fulfillment

  • Handle Gemini responses that do not include candidates
  • Return Gemini error messages when the API responds with an explicit error.message
  • Preserve the existing fallback message for unexpected response shape t('AI_Something_Went_Wrong', this.language).

Proposed changes (including videos or screenshots)

This PR improves Gemini response handling in /quick ai.

Previously, the Gemini execution path assumed that every successful-looking response contained generated text at:

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

In practice, Gemini can return an error payload instead, for example when the model is overloaded or temporarily unavailable. In those cases, candidates may be missing, which caused the quick AI flow to fail.

This change:

  • checks for response.data.error.message
  • returns the provider error message when available
  • safely handles responses where generated candidate text is missing
  • keeps the existing fallback behavior for unexpected response shapes
image

Further comments

console.log is used here for debugging because it was the most reliable way to inspect the Gemini response payload in the current local setup run, whereas this.app.getLogger() output was not consistently visible during investigation.

This PR is intentionally scoped to Gemini runtime response handling only.

It does not change the broader /quick ai interaction flow or AI configuration behavior.

@CodeMatrix1
Copy link
Copy Markdown
Author

Hi vipin, let me know if you want me to keep console.log or use this.app.getLogger(), i will make a change or if you want a new PR immdiately

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant