chennaji9 opened a new pull request, #6846:
URL: https://github.com/apache/rocketmq-dashboard/pull/6846

   ### Which Issue(s) This PR Fixes
   
   None — small self-contained fix found by inspection (no issue tracked).
   
   ### Brief Description
   
   The OpenAI-compatible gateway client disables redirects 
(`HttpClient.Redirect.NEVER`), but every response check only treats 
`statusCode() >= 400` as a failure — in `complete()`, `listModels()`, 
`stream()`, and the streaming body handler's error-body routing.
   
   So when a provider answers 301/302/307 (a misconfigured base URL pointing at 
a login portal, or an http→https redirect), the empty or HTML body is handed to 
the JSON/SSE parsers instead of being reported: `complete()` fails with a 
confusing parse error (or worse, an empty completion), and `stream()` sees no 
`data:` lines and simply ends — a run that produced no answer can be recorded 
as a normal completion.
   
   All four checks now use one `isUpstreamFailure` helper: anything outside 2xx 
is an upstream failure, and the streaming path routes non-2xx bodies to the 
error-body branch so the status and whatever body exists are preserved in the 
`LlmGatewayException`.
   
   ### How Did You Test This Change?
   
   `mvn -B -ntp test -Dtest=OpenAiCompatibleLlmClientTest` → **Tests run: 32, 
Failures: 0** (29 existing + 3 new).
   
   New cases against a loopback `HttpServer` fixture (no external service):
   - `completeShouldRejectARedirectResponse` — 302 with an empty HTML body 
raises the gateway exception naming `status 302`;
   - `streamShouldRejectARedirectResponse` — 307 with a `Location` header 
raises the exception and no tokens reach the consumer;
   - `listModelsShouldRejectARedirectResponse` — 302 on the models endpoint 
raises instead of parsing.
   
   Red side: all three tests against the unfixed client fail — the redirect 
bodies went to the parsers (the stream case completes "successfully" with zero 
tokens).
   
   ### Checklist
   
   - [x] One coherent change; unrelated modifications are not bundled in
   - [x] Commit subject follows Conventional Commits (`fix:`)
   - [x] Tests added or updated for non-trivial changes (3 new red-green tests 
across both request paths)
   - [x] New UI text has both Chinese and English entries under `web/src/i18n/` 
(n/a — no UI change)
   - [x] Architecture constraints stay green (same module, no new dependency)
   - [x] New source files carry the ASF license header (n/a — no new source 
file)
   - [x] Documentation touched where behaviour changed (n/a — non-2xx was never 
a documented success)
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to