{"record":{"id":"b742555c0f7217ba","repo":"openai/codex-plugin-cc","slug":"no-active-job-found-for-reference","errorCode":null,"errorMessage":"No active job found for \"${reference}\".","messagePattern":"No active job found for \"(.+?)\"\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"plugins/codex/scripts/lib/job-control.mjs","lineNumber":289,"sourceCode":"    throw new Error(`Job ${active.id} is still ${active.status}. Check /codex:status and try again once it finishes.`);\n  }\n\n  if (reference) {\n    throw new Error(`No finished job found for \"${reference}\". Run /codex:status to inspect active jobs.`);\n  }\n\n  throw new Error(\"No finished Codex jobs found for this repository yet.\");\n}\n\nexport function resolveCancelableJob(cwd, reference, options = {}) {\n  const workspaceRoot = resolveWorkspaceRoot(cwd);\n  const jobs = sortJobsNewestFirst(listJobs(workspaceRoot));\n  const activeJobs = jobs.filter((job) => job.status === \"queued\" || job.status === \"running\");\n\n  if (reference) {\n    const selected = matchJobReference(activeJobs, reference);\n    if (!selected) {\n      throw new Error(`No active job found for \"${reference}\".`);\n    }\n    return { workspaceRoot, job: selected };\n  }\n\n  const sessionScopedActiveJobs = filterJobsForCurrentSession(activeJobs, options);\n\n  if (sessionScopedActiveJobs.length === 1) {\n    return { workspaceRoot, job: sessionScopedActiveJobs[0] };\n  }\n  if (sessionScopedActiveJobs.length > 1) {\n    throw new Error(\"Multiple Codex jobs are active. Pass a job id to /codex:cancel.\");\n  }\n\n  if (getCurrentSessionId(options)) {\n    throw new Error(\"No active Codex jobs to cancel for this session.\");\n  }\n\n  throw new Error(\"No active Codex jobs to cancel.\");","sourceCodeStart":271,"sourceCodeEnd":307,"githubUrl":"https://github.com/openai/codex-plugin-cc/blob/db52e28f4d9ded852ab3942cea316258ae4ef346/plugins/codex/scripts/lib/job-control.mjs#L271-L307","documentation":"Thrown by resolveCancelableJob() when a reference is supplied but it matches no job in the active set (queued|running). matchJobReference over the active-only list returned null (the helper does not throw on a clean miss, only on ambiguity). So the id either does not exist or refers to an already-finished job.","triggerScenarios":"Calling resolveCancelableJob(cwd, ref) where ref is not a prefix/exact match of any currently queued or running job. Reached via /codex:cancel <id>.","commonSituations":"Trying to cancel a job that already completed/failed; typo in id; id from another session; race where the job finished between the status check and the cancel.","solutions":["Run /codex:status and confirm which jobs are still active before cancelling.","If the job already finished, no cancellation is needed.","Re-copy the id and retry, or cancel with no reference if exactly one job is active."],"exampleFix":"// before\nresolveCancelableJob(cwd, \"done-id\");\n\n// after\nconst snap = buildStatusSnapshot(cwd);\nconst activeId = snap.running[0]?.id;\nif (activeId) resolveCancelableJob(cwd, activeId);","handlingStrategy":"validation","validationCode":"function isActiveMatch(jobs, reference) {\n  const active = jobs.filter((j) => [\"queued\", \"running\"].includes(j.status));\n  return active.some((j) => j.id === reference || j.id.startsWith(reference));\n}\n\nconst jobs = listJobs(workspaceRoot);\nif (reference && !isActiveMatch(jobs, reference)) {\n  throw new Error(`No active job matches '${reference}'.`);\n}","typeGuard":"function isActiveJob(job) {\n  return job != null && [\"queued\", \"running\"].includes(job.status);\n}","tryCatchPattern":"try {\n  resolveCancelableJob(cwd, ref);\n} catch (err) {\n  if (/No active job found/.test(err.message)) {\n    const snap = buildStatusSnapshot(cwd);\n    if (snap.running.length === 0) console.log(\"Nothing to cancel.\");\n  } else throw err;\n}","preventionTips":["Verify the job is still active via /codex:status before cancelling.","Cancel promptly after deciding to — jobs can finish between status and cancel.","If exactly one job is active, omit the reference rather than risking a stale id."],"tags":["job-control","not-found","codex","cancel"],"backgroundTag":null,"analyzedSha":"db52e28f4d9ded852ab3942cea316258ae4ef346","analyzedAt":"2026-08-13T05:13:20.855Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}