{"record":{"id":"e41d111319c3d434","repo":"Mintplex-Labs/anything-llm","slug":"only-running-or-queued-jobs-can-be-killed","errorCode":null,"errorMessage":"Only running or queued jobs can be killed","messagePattern":"Only running or queued jobs can be killed","errorType":"http","errorClass":null,"httpStatus":400,"severity":"error","filePath":"server/endpoints/scheduledJobs.js","lineNumber":98,"sourceCode":"            await ScheduledJobRun.continueInThread(\n              Number(request.params.runId)\n            );\n          if (error) return response.status(500).json({ error });\n\n          return response.status(200).json({\n            workspaceSlug: workspace.slug,\n            threadSlug: thread.slug,\n          });\n        }\n\n        if (action === \"kill\") {\n          const run = await ScheduledJobRun.get({\n            id: Number(request.params.runId),\n          });\n          if (!run)\n            return response.status(404).json({ error: \"Run not found\" });\n          if (![\"queued\", \"running\"].includes(run.status)) {\n            return response.status(400).json({\n              error: \"Only running or queued jobs can be killed\",\n            });\n          }\n\n          const killed = backgroundService.killRun(run.jobId, run.id);\n          if (!killed) await ScheduledJobRun.kill(run.id);\n          return response.status(200).json({ success: true });\n        }\n      } catch {\n        response.sendStatus(500);\n      }\n    }\n  );\n\n  // List all scheduled jobs\n  app.get(\n    \"/scheduled-jobs\",\n    [validatedRequest, isSingleUserMode],","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/3aec848f2885144aa8f1e53b9731a04310d5d558/server/endpoints/scheduledJobs.js#L80-L116","documentation":"State guard on the run kill action: the run exists but its status is neither 'queued' nor 'running', so there is no active execution to terminate and the kill request is rejected as invalid for the run's current state.","triggerScenarios":"Thrown at server/endpoints/scheduledJobs.js:98 when the library encounters an invalid state.","commonSituations":"Attempting to kill a scheduled job that already completed or failed.","solutions":["Only kill jobs whose status is running or queued.","Refresh the job status before issuing the kill."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3aec848f2885144aa8f1e53b9731a04310d5d558","analyzedAt":"2026-08-18T10:02:21.017Z","contentChangedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}