[Bug 28020] New: Error responses should return a code
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28020 Bug ID: 28020 Summary: Error responses should return a code Change sponsored?: --- Product: Koha Version: master Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: REST API Assignee: koha-bugs@lists.koha-community.org Reporter: tomascohen@gmail.com Right now, many error conditions on the REST API correctly return an error status (e.g. 500, 400, 403, etc) and a nice description of the error (e.g. "Anonymous patron cannot be deleted"). But, in order to ease building translatable UIs based on the REST API, we need to add an 'error_code' attribute, and probably a payload to the responses for using later to query a key/value collection (or similar). -- 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=28020 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|koha-bugs@lists.koha-commun |tomascohen@gmail.com |ity.org | -- 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=28020 David Cook <dcook@prosentient.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |dcook@prosentient.com.au --- Comment #1 from David Cook <dcook@prosentient.com.au> --- +1 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28020 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jonathan.druart+koha@gmail. | |com, | |martin.renvoize@ptfs-europe | |.com -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28020 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28020 --- Comment #2 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Created attachment 128915 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=128915&action=edit Bug 28020: Unit tests The unhandled_exception() Mojo helper didn't have proper tests. As this bug is adding a slight behavior change, I tried to add some. As it relies on the OpenAPI plugin, it cannot be done the usual way using Mojo::Lite. So I picked a route and forced an exception through mocking to be able to write tests. To test: 1. Apply this patch 2. Run: $ kshell k$ prove t/db_dependent/api/v1/unhandled_exceptions.t => FAIL: The unhandled_exception() helper doesn't return an error_code in the response payload. Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28020 --- Comment #3 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Created attachment 128916 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=128916&action=edit Bug 28020: Add error_code to error responses This patch adds the *error_code* attribute to the error response definition. This way it can be added when returning an error. I also made a sample usage of it on the generic unhandled_exception helper, which the unit tests on this patchset expect. To test: 1. Apply the unit tests patch 2. Run: $ kshell k$ prove t/db_dependent/api/v1/unhandled_exceptions.t => FAIL: The unhandled_exception() helper doesn't return an error_code in the response payload. 3. Apply this patch 4. Repeat 2 => SUCCESS: Tests pass! Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28020 --- Comment #4 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Created attachment 128917 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=128917&action=edit Bug 28020: (follow-up) Add docs about error_code on the API This patch intends to be a guide for inserting Markdown documentation for error codes. The idea is that it can be copied and pasted as-is in new routes. And adapted to new error codes. To test: 1. Apply this patch 2. Run: $ npx redoc-cli@0.10.4 bundle --cdn --output index.html \ api/v1/swagger/swagger.yaml => SUCCESS: It builds correctly 3. Open index.tml on your browser 4. Pick a route, and see the 500 status description includes information about the possible `error_code` values. 5. Sign off :-D Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28020 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Depends on| |29620 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29620 [Bug 29620] Move the OpenAPI spec to YAML format -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28020 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |29772 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29772 [Bug 29772] Make DELETE /patrons return error codes in error conditions -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28020 Andrew Fuerste-Henry <andrew@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28020 Andrew Fuerste-Henry <andrew@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #128915|0 |1 is obsolete| | --- Comment #5 from Andrew Fuerste-Henry <andrew@bywatersolutions.com> --- Created attachment 128918 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=128918&action=edit Bug 28020: Unit tests The unhandled_exception() Mojo helper didn't have proper tests. As this bug is adding a slight behavior change, I tried to add some. As it relies on the OpenAPI plugin, it cannot be done the usual way using Mojo::Lite. So I picked a route and forced an exception through mocking to be able to write tests. To test: 1. Apply this patch 2. Run: $ kshell k$ prove t/db_dependent/api/v1/unhandled_exceptions.t => FAIL: The unhandled_exception() helper doesn't return an error_code in the response payload. Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28020 Andrew Fuerste-Henry <andrew@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #128916|0 |1 is obsolete| | --- Comment #6 from Andrew Fuerste-Henry <andrew@bywatersolutions.com> --- Created attachment 128919 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=128919&action=edit Bug 28020: Add error_code to error responses This patch adds the *error_code* attribute to the error response definition. This way it can be added when returning an error. I also made a sample usage of it on the generic unhandled_exception helper, which the unit tests on this patchset expect. To test: 1. Apply the unit tests patch 2. Run: $ kshell k$ prove t/db_dependent/api/v1/unhandled_exceptions.t => FAIL: The unhandled_exception() helper doesn't return an error_code in the response payload. 3. Apply this patch 4. Repeat 2 => SUCCESS: Tests pass! Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28020 Andrew Fuerste-Henry <andrew@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #128917|0 |1 is obsolete| | --- Comment #7 from Andrew Fuerste-Henry <andrew@bywatersolutions.com> --- Created attachment 128920 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=128920&action=edit Bug 28020: (follow-up) Add docs about error_code on the API This patch intends to be a guide for inserting Markdown documentation for error codes. The idea is that it can be copied and pasted as-is in new routes. And adapted to new error codes. To test: 1. Apply this patch 2. Run: $ npx redoc-cli@0.10.4 bundle --cdn --output index.html \ api/v1/swagger/swagger.yaml => SUCCESS: It builds correctly 3. Open index.tml on your browser 4. Pick a route, and see the 500 status description includes information about the possible `error_code` values. 5. Sign off :-D Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28020 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Depends on| |29018 --- Comment #8 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Rebasing on top of bug 29018 as that one needs to be backportable. Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29018 [Bug 29018] Deleting patrons from REST API doesn't do any checks or move to deletedborrowers -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28020 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #128918|0 |1 is obsolete| | --- Comment #9 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Created attachment 128921 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=128921&action=edit Bug 28020: Unit tests The unhandled_exception() Mojo helper didn't have proper tests. As this bug is adding a slight behavior change, I tried to add some. As it relies on the OpenAPI plugin, it cannot be done the usual way using Mojo::Lite. So I picked a route and forced an exception through mocking to be able to write tests. To test: 1. Apply this patch 2. Run: $ kshell k$ prove t/db_dependent/api/v1/unhandled_exceptions.t => FAIL: The unhandled_exception() helper doesn't return an error_code in the response payload. Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28020 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #128919|0 |1 is obsolete| | --- Comment #10 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Created attachment 128922 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=128922&action=edit Bug 28020: Add error_code to error responses This patch adds the *error_code* attribute to the error response definition. This way it can be added when returning an error. I also made a sample usage of it on the generic unhandled_exception helper, which the unit tests on this patchset expect. To test: 1. Apply the unit tests patch 2. Run: $ kshell k$ prove t/db_dependent/api/v1/unhandled_exceptions.t => FAIL: The unhandled_exception() helper doesn't return an error_code in the response payload. 3. Apply this patch 4. Repeat 2 => SUCCESS: Tests pass! Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28020 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #128920|0 |1 is obsolete| | --- Comment #11 from Tomás Cohen Arazi <tomascohen@gmail.com> --- Created attachment 128923 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=128923&action=edit Bug 28020: (follow-up) Add docs about error_code on the API This patch intends to be a guide for inserting Markdown documentation for error codes. The idea is that it can be copied and pasted as-is in new routes. And adapted to new error codes. To test: 1. Apply this patch 2. Run: $ npx redoc-cli@0.10.4 bundle --cdn --output index.html \ api/v1/swagger/swagger.yaml => SUCCESS: It builds correctly 3. Open index.tml on your browser 4. Pick a route, and see the 500 status description includes information about the possible `error_code` values. 5. Sign off :-D Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28020 Jonathan Druart <jonathan.druart+koha@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Passed QA -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28020 Jonathan Druart <jonathan.druart+koha@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #128921|0 |1 is obsolete| | Attachment #128922|0 |1 is obsolete| | Attachment #128923|0 |1 is obsolete| | --- Comment #12 from Jonathan Druart <jonathan.druart+koha@gmail.com> --- Created attachment 128961 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=128961&action=edit Bug 28020: Unit tests The unhandled_exception() Mojo helper didn't have proper tests. As this bug is adding a slight behavior change, I tried to add some. As it relies on the OpenAPI plugin, it cannot be done the usual way using Mojo::Lite. So I picked a route and forced an exception through mocking to be able to write tests. To test: 1. Apply this patch 2. Run: $ kshell k$ prove t/db_dependent/api/v1/unhandled_exceptions.t => FAIL: The unhandled_exception() helper doesn't return an error_code in the response payload. Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28020 --- Comment #13 from Jonathan Druart <jonathan.druart+koha@gmail.com> --- Created attachment 128962 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=128962&action=edit Bug 28020: Add error_code to error responses This patch adds the *error_code* attribute to the error response definition. This way it can be added when returning an error. I also made a sample usage of it on the generic unhandled_exception helper, which the unit tests on this patchset expect. To test: 1. Apply the unit tests patch 2. Run: $ kshell k$ prove t/db_dependent/api/v1/unhandled_exceptions.t => FAIL: The unhandled_exception() helper doesn't return an error_code in the response payload. 3. Apply this patch 4. Repeat 2 => SUCCESS: Tests pass! Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28020 --- Comment #14 from Jonathan Druart <jonathan.druart+koha@gmail.com> --- Created attachment 128963 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=128963&action=edit Bug 28020: (follow-up) Add docs about error_code on the API This patch intends to be a guide for inserting Markdown documentation for error codes. The idea is that it can be copied and pasted as-is in new routes. And adapted to new error codes. To test: 1. Apply this patch 2. Run: $ npx redoc-cli@0.10.4 bundle --cdn --output index.html \ api/v1/swagger/swagger.yaml => SUCCESS: It builds correctly 3. Open index.tml on your browser 4. Pick a route, and see the 500 status description includes information about the possible `error_code` values. 5. Sign off :-D Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28020 Fridolin Somers <fridolin.somers@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Version(s)| |22.05.00 released in| | Status|Passed QA |Pushed to master -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28020 --- Comment #15 from Fridolin Somers <fridolin.somers@biblibre.com> --- Pushed to master for 22.05, thanks to everybody involved 🦄 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28020 Tomás Cohen Arazi <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- QA Contact| |jonathan.druart+koha@gmail. | |com Text to go in the| |This development makes our release notes| |error responses include an | |`error_code` that will be | |documented on each route, | |allowing better API usage | |on error conditions. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=28020 Kyle M Hall <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |kyle@bywatersolutions.com Resolution|--- |FIXED Status|Pushed to master |RESOLVED -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org