If a REST auth error happens that that is unblessed or uncaught, we should warn the value to the logs. Test Plan: 1) Install the curbside pickups plugin 2) create a patron with the userid 'puser' and the cardnumber 'pcard' 3) GET /api/v1/contrib/curbsidepickup/patrons/XXX/pickups using basic auth with the username 'pcard' where XXX is the patron borrowernumber 4) Note there is no error in the logs
Created attachment 163856 [details] [review] Bug 36421: REST API 500 errors say to check the logs, but suppress errors that would be there If a REST auth error happens that that is unblessed or uncaught, we should warn the value to the logs. Test Plan: 1) Install the curbside pickups plugin 2) create a patron with the userid 'puser' and the cardnumber 'pcard' 3) GET /api/v1/contrib/curbsidepickup/patrons/XXX/pickups using basic auth with the username 'pcard' where XXX is the patron borrowernumber 4) Note there is no error in the logs 5) Apply this patch 6) Repeat step 3 7) You should now see an error in the logs!
I noticed a bug in the basic Auth code that makes it easy to highlight this issue. If you don't mind, Kyle, I'll provide an alternate patch for this.
Created attachment 163994 [details] [review] Bug 36421: Make sure pre-controller errors are correctly logged If something explodes in Koha::REST::V1::Auth chances are that no logging will happen. This patch makes sure they are! To test: 1. Make sure you do NOT have 36420 on your tree 2. Make sure you are looking at the logs: $ ktd --shell k$ koha-plack --restart kohadev; tail -f /var/log/koha/kohadev/*.log 3. Use Postman or similar for hitting some known endpoint. Use the user's cardnumber instead of the userid. On a default KTD launch, the generated user's cardnumber is '42'. GET /patrons => FAIL: You get a 500 error (expected, fixed on 36420) but no useful logging found. 4. Apply this patch 5. Ctrl+c on the logs and re-run the command 6. Repeat 3 => SUCCESS: You get a 500, but you also get the exception information logged! 7. Sign off :-D
Created attachment 163995 [details] [review] Bug 36421: Make sure pre-controller errors are correctly logged If something explodes in Koha::REST::V1::Auth chances are that no logging will happen. This patch makes sure they are! To test: 1. Make sure you do NOT have 36420 on your tree 2. Make sure you are looking at the logs: $ ktd --shell k$ koha-plack --restart kohadev; tail -f /var/log/koha/kohadev/*.log 3. Use Postman or similar for hitting some known endpoint. Use the user's cardnumber instead of the userid. On a default KTD launch, the generated user's cardnumber is '42'. GET /patrons => FAIL: You get a 500 error (expected, fixed on 36420) but no useful logging found. 4. Apply this patch 5. Ctrl+c on the logs and re-run the command 6. Repeat 3 => SUCCESS: You get a 500, but you also get the exception information logged! 7. Sign off :-D Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Created attachment 164117 [details] [review] Bug 36421: Make sure pre-controller errors are correctly logged If something explodes in Koha::REST::V1::Auth chances are that no logging will happen. This patch makes sure they are! To test: 1. Make sure you do NOT have 36420 on your tree 2. Make sure you are looking at the logs: $ ktd --shell k$ koha-plack --restart kohadev; tail -f /var/log/koha/kohadev/*.log 3. Use Postman or similar for hitting some known endpoint. Use the user's cardnumber instead of the userid. On a default KTD launch, the generated user's cardnumber is '42'. GET /patrons => FAIL: You get a 500 error (expected, fixed on 36420) but no useful logging found. 4. Apply this patch 5. Ctrl+c on the logs and re-run the command 6. Repeat 3 => SUCCESS: You get a 500, but you also get the exception information logged! 7. Sign off :-D Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> [OK] prove t/db_dependent/api/v1/items.t t/db_dependent/api/v1/unhandled_exceptions.t
Pushed for 24.05! Well done everyone, thank you!
Pushed to 23.11.x for 23.11.06
Backported to 23.05.x for upcoming 23.05.12