fix: return error on non-2xx response in stream_generate_content (#3) #4

Merged
andreban merged 2 commits from fix/stream-non-2xx-handling into main 2026-10-18 22:54:24 +01:00
Owner

Fixes #3

Before building the event stream in GeminiClient::stream_generate_content, check response.status(). On a non-success status, parse the body as GenerateContentResponseError when possible (returning Error::VertexError) and fall back to Error::HttpStatus with the HTTP status and raw text.

Includes unit tests covering:

  • 400 Vertex API error JSON response
  • 500 non-JSON error response fallback
  • 200 OK SSE streaming
Fixes #3 Before building the event stream in GeminiClient::stream_generate_content, check response.status(). On a non-success status, parse the body as GenerateContentResponseError when possible (returning Error::VertexError) and fall back to Error::HttpStatus with the HTTP status and raw text. Includes unit tests covering: - 400 Vertex API error JSON response - 500 non-JSON error response fallback - 200 OK SSE streaming
andreban added 1 commit 2026-10-18 22:48:04 +01:00
fix: return error on non-2xx response in stream_generate_content (#3)
Some checks failed
Rust / build (pull_request) Has been cancelled
ba9870277c
Check response.status() before building the SSE event stream. On non-success
status, parse the response body as GenerateContentResponseError when
possible (returning Error::VertexError), and fall back to Error::HttpStatus
with the status code and raw text. Adds tests for HTTP 400 Vertex error,
non-JSON HTTP 500 error, and successful 200 SSE streaming.
andreban added 1 commit 2026-10-18 22:52:44 +01:00
test: move client unit tests to sibling client_tests.rs per rust-testing conventions
Some checks failed
Rust / build (pull_request) Has been cancelled
9bade7a1e6
andreban merged commit ebb49eb929 into main 2026-10-18 22:54:24 +01:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: andreban/gemini-rs#4