https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44114

--- Comment #2 from Jonathan Druart <[email protected]> ---
Created attachment 211623
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=211623&action=edit
Bug 44114: Do not let return_response or non-JSON bypass error handling

In the non-Vue HttpClient, `return_response || !is_json` returned the raw
Response before response.ok was checked. As a result:

- a non-JSON error response (a proxy's HTML 502 page, an HTML login page
  after the session expired, ...) resolved as if it had succeeded,
  without throwing or showing the error dialog, which is exactly what
  bug 43516 set out to guard against;
- every DELETE (return_response defaults to true) resolved on failure,
  so callers ran their success handler (e.g. deleting a vendor
  redirected to the vendor list even when the deletion was refused);
- return_response silently meant "and skip error handling" too,
  overlapping with config.suppressDefaultErrorDialog.

Check response.ok first, as the Vue HttpClient does, and only then
return the raw Response for return_response or non-JSON bodies (e.g. an
empty 204). return_response now only controls the shape of a successful
result; suppressDefaultErrorDialog is the one way to skip the dialog.

Test plan:
1. Run: yarn cypress run --component --browser electron --spec
  
't/cypress/component/HttpClient_spec.ts,t/cypress/component/VueHttpClient_spec.ts'
2. Verify all specs pass.
3. Revert the http-client.js change, run again: the three new failure
   specs fail.
4. Delete a cover image, a club and a localization string: still works.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

-- 
You are receiving this mail because:
You are watching all bug changes.
You are the assignee for the bug.
_______________________________________________
Koha-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to