kolibri icon indicating copy to clipboard operation
kolibri copied to clipboard

Task list returns 500 JobNotFound when a job is cleared mid-request

Open rtibblesbot opened this issue 1 week ago • 0 comments

❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.

Target branch: develop

Observed behavior

GET /api/tasks/tasks/ sometimes returns 500 when another request clears a finished job while the list is being built. list reads every job with get_all_jobs, then _job_to_response re-reads each one with get_orm_job, which raises JobNotFound for a job deleted in between.

Errors and logs

JobNotFound at /api/tasks/tasks/
No exception message supplied
  kolibri/core/tasks/viewsets/tasks.py: jobs_response.append(self._job_to_response(job))
  kolibri/core/tasks/viewsets/tasks.py: orm_job = job_storage.get_orm_job(job_id=job.job_id)
  kolibri/core/tasks/storage.py: raise JobNotFound() from e

Browser console on Facility > Data:

[ERROR: kolibri/plugins/facility/frontend/modules/manageCSV/actions.js] There was an error while fetching the task list:  AxiosError: Request failed with status code 500

User-facing consequences

  • Facility > Data skips one export-status update and logs a console error; the next 1 s poll recovers.

Steps to reproduce

  1. Sign in as a facility admin and open Facility > Data.
  2. Under "Session logs" click Generate log, pick a start and end date, click Generate; then click Generate new user CSV file.
  3. While both run, request /api/tasks/tasks/ in a loop every 50–100 ms in another tab.
  4. Within a few runs, one response is a 500 whose title is JobNotFound at /api/tasks/tasks/.

Context

  • Kolibri 0.20.0a2 dev server, develop at 886a0c9f; Chromium (Playwright).
  • Same unhandled JobNotFound class as closed #10305 (zeroconf disconnect handler); its fix did not cover the task list.

Acceptance Criteria

  • [ ] GET /api/tasks/tasks/ returns 200 when a listed job is deleted before its response entry is built; the deleted job is absent from the response.
  • [ ] A test deletes a job between get_all_jobs and building its entry, and asserts a 200 that omits it.

AI usage

Claude Code hit this error while running manual QA on PR #15825. It captured the traceback and drafted this issue.

rtibblesbot avatar Nov 23 '26 01:11 rtibblesbot