Bug 28804

Summary: 500 Error when running report with bad syntax
Product: Koha Reporter: jstallings
Component: ReportsAssignee: Jonathan Druart <jonathan.druart>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: major    
Priority: P5 - low CC: didier.gautheron, fridolin.somers, jonathan.druart, kyle
Version: unspecified   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
21.11.00,21.05.03
Bug Depends on: 25026    
Bug Blocks:    
Attachments: Bug 28804: (bug 25026 follow-up) Handle SQL errors in reports
Bug 28804: (bug 25026 follow-up) Handle SQL errors in reports
Bug 28804: (bug 25026 follow-up) Handle SQL errors in reports

Description jstallings 2021-08-03 12:56:57 UTC
In previous versions, running an SQL report with an error (typo, bad syntax) would yield an error page with the problem syntax highlighted. 21.05 returns only a 500 error. Excerpt from plack-intranet-error.log here: https://pastebin.com/0UCYkU46
Comment 1 Jonathan Druart 2021-08-04 07:01:26 UTC
Certainly caused by bug 25026.
Comment 2 Jonathan Druart 2021-08-04 07:04:56 UTC
Created attachment 123446 [details] [review]
Bug 28804: (bug 25026 follow-up) Handle SQL errors in reports

Since bug 25026 DBMS errors are raised, but the report module is not
dealing correctly with the errors.
If an error occurred in execute_query, next queries will fail as well,
we should skip them.

Test plan:
1. Create report from SQL queries, containing errors (invalid syntax, etc.)
'SELECT id FROM borrowers' can do it
2. Execute the query
=> Without this patch you get a 500
=> With this patch applied you see that the error raised at DBMS level
is propagated to the UI
3. Confirm that there is no regression on valid queries
Comment 3 Owen Leonard 2021-08-04 16:58:27 UTC
Created attachment 123461 [details] [review]
Bug 28804: (bug 25026 follow-up) Handle SQL errors in reports

Since bug 25026 DBMS errors are raised, but the report module is not
dealing correctly with the errors.
If an error occurred in execute_query, next queries will fail as well,
we should skip them.

Test plan:
1. Create report from SQL queries, containing errors (invalid syntax, etc.)
'SELECT id FROM borrowers' can do it
2. Execute the query
=> Without this patch you get a 500
=> With this patch applied you see that the error raised at DBMS level
is propagated to the UI
3. Confirm that there is no regression on valid queries

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 4 Katrin Fischer 2021-08-10 13:11:05 UTC
Created attachment 123686 [details] [review]
Bug 28804: (bug 25026 follow-up) Handle SQL errors in reports

Since bug 25026 DBMS errors are raised, but the report module is not
dealing correctly with the errors.
If an error occurred in execute_query, next queries will fail as well,
we should skip them.

Test plan:
1. Create report from SQL queries, containing errors (invalid syntax, etc.)
'SELECT id FROM borrowers' can do it
2. Execute the query
=> Without this patch you get a 500
=> With this patch applied you see that the error raised at DBMS level
is propagated to the UI
3. Confirm that there is no regression on valid queries

Signed-off-by: Owen Leonard <oleonard@myacpl.org>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 5 Jonathan Druart 2021-08-11 11:24:15 UTC
Pushed to master for 21.11, thanks to everybody involved!
Comment 6 Kyle M Hall 2021-08-13 11:29:26 UTC
Pushed to 21.05.x for 21.05.03
Comment 7 Fridolin Somers 2021-08-13 19:52:37 UTC
Depends on Bug 25026 not in 20.11.x
Comment 8 Didier Gautheron 2022-10-06 12:51:03 UTC
*** Bug 28287 has been marked as a duplicate of this bug. ***