You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: HayStackClient treats a non-2xx response as a successful retrieval #4130
HayStackClient.retrieve logs a non-2xx status and then parses the body anyway. The only failure check after that is code != null && code != successCode, so an error response whose body carries no code field (a gateway 502/503, or a proxy error page that happens to be JSON) comes back to the caller as a successful retrieval with no documents.
To Reproduce
Point a HayStackConfig at an endpoint that answers 503 with {"error": "service unavailable"}, then call client.retrieve("q", null, null).block(). It returns a HayStackResponse with no documents instead of failing.
Relevant code (HayStackClient.retrieve, around line 235):
if (!response.isSuccessful()) {
logger.error("HayStack API error: status={}, body={}", response.code(), responseBody);
}
HayStackResponsehayStackResponse =
JsonUtils.getJsonCodec().fromJson(responseBody, HayStackResponse.class);
if (hayStackResponse.getCode() != null
&& !hayStackResponse.getCode().equals(config.getSuccessCode())) {
thrownewHayStackApiException(...);
}
returnhayStackResponse;
Expected behavior
A non-2xx status fails the retrieval. The other RAG clients already behave this way: DifyRAGClient throws from handleErrorResponse before parsing.
Error messages
None, which is the problem: the caller sees an empty result and no indication that the upstream call failed.
Environment (please complete the following information):
AgentScope-Java Version: 2.1.0-SNAPSHOT (main at 2d70942c)
Java Version: 17
OS: Windows 11
Additional context
A 200 whose body carries no code field is left alone: it is indistinguishable from a response with no documents, and this report is only about the transport-level signal.
I have a fix and a test ready and will open a PR if this is a real defect.
Activity