Bug 42705: Make http-client.js handle svc endpoint error

The afterEach calls cy.login() then immediately posts to the syspref endpoint. On CI, the machine is slow enough that the POST fires before the login
redirect completes — no valid session yet — so the endpoint returns a C4::Service auth error in this format:

{ "type": "auth", "message": "expired" }

http-client.js only knew how to parse modern REST API errors (json.error or json.errors[]). Neither field exists here, so json.errors.map(...) crashed with a TypeError instead of surfacing the actual error message.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Pedro Amorim 2026-06-01 10:43:33 +00:00 committed by Lucas Gass
parent 87a552d8a7
commit 4e87782636
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
1 changed files with 2 additions and 1 deletions

View File

@ -80,7 +80,8 @@ class HttpClient {
let json = JSON.parse(text);
message =
json.error ||
json.errors.map(e => e.message).join("\n") ||
json.errors?.map(e => e.message).join("\n") ||
json.message ||
json;
} else {
message = response.statusText;