[Bug 44114] New: HttpClient: failed requests can resolve as success, and return_response overlaps with suppressDefaultErrorDialog
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44114 Bug ID: 44114 Summary: HttpClient: failed requests can resolve as success, and return_response overlaps with suppressDefaultErrorDialog Initiative type: --- Sponsorship --- status: Product: Koha Version: unspecified Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: Architecture, internals, and plumbing Assignee: koha-bugs@lists.koha-community.org Reporter: jonathan.druart@gmail.com QA Contact: testopia@bugs.koha-community.org Target Milestone: --- -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44114 Jonathan Druart <jonathan.druart@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |In Discussion -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44114 --- Comment #1 from Jonathan Druart <jonathan.druart@gmail.com> --- Created attachment 211622 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=211622&action=edit Bug 44114: Use thrown error details when adding to a bundle The "Add to bundle" form asked the HttpClient for the raw Response (return_response) only so that it could inspect the status and error_code of a failed request itself. The client now attaches both to the thrown error, so suppress the default error dialog and branch on error.status/error.code instead. This removes the last caller relying on return_response to skip the client's error handling. Test plan: 1. Create a bundle (an item with a 'Collection' material type) and open its record's detail page, Holdings tab, "Manage bundle". 2. Add an item by barcode: "Success: Added '...'" is displayed. 3. Add the same barcode again: "Warning: Item '...' already attached". 4. Add an unknown barcode: "Failure: Item '...' not found". 5. Add a checked-out item: the "Check in and add to bundle" button is displayed and works. 6. Add an item on hold: the "Ignore holds and add to bundle" button is displayed and works. 7. Confirm no extra warning appears at the top of the page for these failures. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44114 --- Comment #2 from Jonathan Druart <jonathan.druart@gmail.com> --- 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 <noreply@anthropic.com> -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44114 --- Comment #3 from Jonathan Druart <jonathan.druart@gmail.com> --- Created attachment 211624 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=211624&action=edit Bug 44114: Remove the unused parseResponse option from delete() Both HttpClients' delete() passed parseResponse: false in the fetch options. Nothing reads it: it was forwarded to fetch(), which ignores unknown options. Whether the response is parsed is controlled by return_response, which delete() already defaults to true. Test plan: 1. git grep parseResponse -- koha-tmpl t ':!*/lib/*' ':!*/dist/*' returns nothing. 2. Run: yarn cypress run --component --browser electron --spec 't/cypress/component/HttpClient_spec.ts,t/cypress/component/VueHttpClient_spec.ts' 3. Verify all specs pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44114 --- Comment #4 from Jonathan Druart <jonathan.druart@gmail.com> --- Created attachment 211625 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=211625&action=edit Bug 44114: Replace return_response with config.rawResponse return_response overlapped with config.suppressDefaultErrorDialog: in the non-Vue client, asking for the raw Response also skipped the error handling. Now that failed requests are always rejected, and the last caller relying on that (adding to a bundle) uses suppressDefaultErrorDialog and the status/code attached to the thrown error, it only selects the shape of a successful result. Remove the return_response parameter from both HttpClients and move that switch to the per-request config object, next to signal and suppressDefaultErrorDialog, as config.rawResponse. delete() and count() always set it: a 204 has no body, and count() reads X-Total-Count. 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. git grep return_response -- koha-tmpl t ':!*/lib/*' ':!*/dist/*' returns nothing. 4. In ERM, check the counts on the module dashboard and the agreements list, then delete an agreement: still works. 5. Delete a vendor, a club and a localization string: still works. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44114 Jonathan Druart <jonathan.druart@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Depends on| |43516 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43516 [Bug 43516] Harden the frontend HttpClient and add a shared API error formatter -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44114 Jonathan Druart <jonathan.druart@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|koha-bugs@lists.koha-commun |jonathan.druart@gmail.com |ity.org | -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=44114 Jonathan Druart <jonathan.druart@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |paul.derscheid@lmscloud.de -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org