Skip to content

fix(rag-haystack): fail the retrieval on a non-2xx response - #4131

Merged
jujn merged 1 commit into
agentscope-ai:mainfrom
ningmao-hlyz:fix/haystack-http-status-fails
Nov 13, 2026
Merged

jujn merged 1 commit into
agentscope-ai:mainfrom
ningmao-hlyz:fix/haystack-http-status-fails

Conversation

@ningmao-hlyz

Copy link
Copy Markdown
Contributor

AgentScope-Java Version

2.1.0-SNAPSHOT (main at 2d70942c)

Description

Fixes #4130.

HayStackClient.retrieve logged a non-2xx status and then parsed the body anyway. The only failure check after that is code != null && code != successCode, so an error body without a code field (a gateway 502/503, or a proxy error page that happens to be JSON) came back to the caller as a successful retrieval with no documents.

This throws HayStackApiException carrying the HTTP status before parsing, and keeps the body in the existing log line. DifyRAGClient already fails on the status the same way.

How to test: mvn -pl agentscope-extensions/agentscope-extensions-rag/agentscope-extensions-rag-haystack test. The new test fails before the change (Expected HayStackApiException to be thrown, but nothing was thrown) and passes after.

A 200 whose body carries no code is untouched: it is indistinguishable from a response with no documents, and this change is scoped to the transport-level signal.

retrieve() logged a non-2xx status and then parsed the body anyway. A gateway
error body carries no code field, so the response came back to the caller as a
successful retrieval with no documents.

Throw HayStackApiException carrying the HTTP status before parsing.
@ningmao-hlyz
ningmao-hlyz force-pushed the fix/haystack-http-status-fails branch from 09446f9 to 96eca93 Compare November 11, 2026 12:37
@jujn
jujn merged commit 865d1de into agentscope-ai:main Nov 13, 2026
5 checks passed
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]: HayStackClient treats a non-2xx response as a successful retrieval

2 participants