Skip to content

fix(translate): harden Gemini WebAPI timeout and error handling - #148

Merged
Amm1rr merged 2 commits into
masterfrom
fix/translate-webapi-error-handling
Oct 14, 2026
Merged

Amm1rr merged 2 commits into
masterfrom
fix/translate-webapi-error-handling

Conversation

@Amm1rr

@Amm1rr Amm1rr commented Oct 14, 2026

Copy link
Copy Markdown
Owner

Summary

Improve /translate resilience for Gemini WebAPI failures.

Changes

  • Add a shared 300-second direct Gemini WebAPI deadline
  • Map known Gemini provider failures to stable HTTP status codes
  • Preserve cancellation and Gemini generation lease cleanup
  • Document /translate error responses in OpenAPI and API contracts
  • Add focused timeout, error mapping, cancellation, and OpenAPI tests
  • Bump version to 0.7.2

Error mapping

  • 429 for usage limits or temporary blocks
  • 502 for Gemini provider or model failures
  • 503 for authentication or service availability failures
  • 504 for request timeout
  • 500 for unexpected errors

Notes

This does not change gemini-webapi retry or recovery behavior and does not attempt to fix the upstream Gemini stream interruption itself. It only bounds request execution and improves WebAI-to-API error handling.

Related issue: #143
Related discussion: #146

Validation

  • Focused /translate tests passed
  • Gemini-related test suite passed
  • Full test suite passed
  • git diff --check passed

- add a shared 300-second direct WebAPI deadline
- map known Gemini failures to stable HTTP statuses
- preserve cancellation and generation lease cleanup
- document translate error responses in OpenAPI and API contracts
- add focused timeout, error mapping, and cancellation tests
@Amm1rr
Amm1rr marked this pull request as ready for review October 14, 2026 11:21
@greptile-apps

greptile-apps Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable defects were found.

Summary

/translate now limits direct Gemini generation to 300 seconds and reuses the shared provider error mapping.

  • Gemini translation calls now stop on time and return mapped errors.

No actionable issues were found. Tests were inspected but not run.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A["POST /translate"] --> B["Acquire client lease"]
  B --> C["Check client and model"]
  C --> D["Generate with temporary=True<br/>300-second deadline"]
  D --> E["Return response text"]
  D --> F["Timeout or provider error"]
  F --> G["Release client lease"]
  G --> H["Map known errors to HTTP status"]
  H --> I["429 / 502 / 503 / 504"]
  H --> J["Unexpected error: 500"]
  D --> K["Request cancelled"]
  K --> L["Release lease and propagate cancellation"]
Loading

Reviews (1) · Last reviewed commit: "chore(release): bump version to 0.7.2" · Reviewed by Greptile

@Amm1rr
Amm1rr merged commit 006a08d into master Oct 14, 2026
1 of 5 checks passed
@Amm1rr
Amm1rr deleted the fix/translate-webapi-error-handling branch October 14, 2026 11:28
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.

1 participant