Bug 32745 - Jobs view breaks when there are jobs with context IS NULL
Summary: Jobs view breaks when there are jobs with context IS NULL
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: System Administration (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal
Assignee: Jonathan Druart
QA Contact: Katrin Fischer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-01-30 14:56 UTC by Katrin Fischer
Modified: 2023-12-28 20:44 UTC (History)
5 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
23.05.00,22.11.06
Circulation function:


Attachments
Bug 32745: Adjust context for invalid background jobs (1.71 KB, patch)
2023-03-24 10:21 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 32745: Adjust context for invalid background jobs (1.76 KB, patch)
2023-04-23 06:55 UTC, David Nind
Details | Diff | Splinter Review
Bug 32745: Adjust context for invalid background jobs (1.82 KB, patch)
2023-04-23 10:08 UTC, Katrin Fischer
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Katrin Fischer 2023-01-30 14:56:13 UTC
In 22.11.01 the background jobs view breaks, when there are entries with context = NULL in the database. In our case these are old entries for "batch_biblio_record_modification" from 2021. Newer entries seem to always have context set. Maybe an update issue with old data?

* Manipulate database
* Go to Administration > Manage jobs
* Uncheck both checkboxes on top of the list if necessary
Comment 1 Katrin Fischer 2023-03-23 14:55:52 UTC
Any idea about this one? I think I saw something similar on the mailing list too.
Comment 2 Jonathan Druart 2023-03-24 10:21:18 UTC
Created attachment 148643 [details] [review]
Bug 32745: Adjust context for invalid background jobs

We had some problems recently and it's possible to have
background_jobs.context=NULL
But the REST API specs is expecting an object.
We could either modify the specs, or adjust the incorrect entries in DB,
which is IMO better.

Test plan:
0. Don't apply the patch
1. Create some background jobs
2. Set context to NULL
UPDATE background_jobs SET context=NULL;
3. List the jobs and note the datatable error, and the error in Koha log
  OpenAPI >>> GET api/v1/jobs [{"message":"Expected object - got null.","path":"\/body\/0\/context"},{"message":"Expected object - got null.","path":"\/body\/1\/context"}]

4. Apply the patch
5. Run `updatedatabase`
6. Confirm that the list and detail view are not working correctly
Comment 3 David Nind 2023-04-23 06:55:26 UTC
Created attachment 150115 [details] [review]
Bug 32745: Adjust context for invalid background jobs

We had some problems recently and it's possible to have
background_jobs.context=NULL
But the REST API specs is expecting an object.
We could either modify the specs, or adjust the incorrect entries in DB,
which is IMO better.

Test plan:
0. Don't apply the patch
1. Create some background jobs
2. Set context to NULL
UPDATE background_jobs SET context=NULL;
3. List the jobs and note the datatable error, and the error in Koha log
  OpenAPI >>> GET api/v1/jobs [{"message":"Expected object - got null.","path":"\/body\/0\/context"},{"message":"Expected object - got null.","path":"\/body\/1\/context"}]

4. Apply the patch
5. Run `updatedatabase`
6. Confirm that the list and detail view are not working correctly

Signed-off-by: David Nind <david@davidnind.com>
Comment 4 David Nind 2023-04-23 06:57:52 UTC
Testing notes (using KTD):

1. To create some background jobs, I started KTD with --es7 then updated the titles for 3 records.

2. For step 6 of the test plan, I think that should say the list and detail views ARE working correctly 8-).
Comment 5 Katrin Fischer 2023-04-23 10:08:00 UTC
Created attachment 150118 [details] [review]
Bug 32745: Adjust context for invalid background jobs

We had some problems recently and it's possible to have
background_jobs.context=NULL
But the REST API specs is expecting an object.
We could either modify the specs, or adjust the incorrect entries in DB,
which is IMO better.

Test plan:
0. Don't apply the patch
1. Create some background jobs
2. Set context to NULL
UPDATE background_jobs SET context=NULL;
3. List the jobs and note the datatable error, and the error in Koha log
  OpenAPI >>> GET api/v1/jobs [{"message":"Expected object - got null.","path":"\/body\/0\/context"},{"message":"Expected object - got null.","path":"\/body\/1\/context"}]

4. Apply the patch
5. Run `updatedatabase`
6. Confirm that the list and detail view are not working correctly

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 6 Katrin Fischer 2023-04-23 10:08:28 UTC
Are we missing a 'success' message in the database update? (is the second output line manatory?)
Comment 7 Tomás Cohen Arazi (tcohen) 2023-05-05 12:17:01 UTC
Pushed to master for 23.05.

Nice work everyone, thanks!
Comment 8 Martin Renvoize (ashimema) 2023-05-11 12:25:36 UTC
Many hands makes light work, thankyou everyone!

Pushed to 22.11.x for the next release