{"record":{"id":"be1ed6c4f1774f93","repo":"openai/codex-plugin-cc","slug":"no-job-found-for-reference-run-codex-status","errorCode":null,"errorMessage":"No job found for \"${reference}\". Run /codex:status to list known jobs.","messagePattern":"No job found for \"(.+?)\"\\. Run /codex:status to list known jobs\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"plugins/codex/scripts/lib/job-control.mjs","lineNumber":210,"sourceCode":"  const filtered = jobs.filter(predicate);\n  if (!reference) {\n    return filtered[0] ?? null;\n  }\n\n  const exact = filtered.find((job) => job.id === reference);\n  if (exact) {\n    return exact;\n  }\n\n  const prefixMatches = filtered.filter((job) => job.id.startsWith(reference));\n  if (prefixMatches.length === 1) {\n    return prefixMatches[0];\n  }\n  if (prefixMatches.length > 1) {\n    throw new Error(`Job reference \"${reference}\" is ambiguous. Use a longer job id.`);\n  }\n\n  throw new Error(`No job found for \"${reference}\". Run /codex:status to list known jobs.`);\n}\n\nexport function buildStatusSnapshot(cwd, options = {}) {\n  const workspaceRoot = resolveWorkspaceRoot(cwd);\n  const config = getConfig(workspaceRoot);\n  const jobs = sortJobsNewestFirst(filterJobsForCurrentSession(listJobs(workspaceRoot), options));\n  const maxJobs = options.maxJobs ?? DEFAULT_MAX_STATUS_JOBS;\n  const maxProgressLines = options.maxProgressLines ?? DEFAULT_MAX_PROGRESS_LINES;\n\n  const running = jobs\n    .filter((job) => job.status === \"queued\" || job.status === \"running\")\n    .map((job) => enrichJob(job, { maxProgressLines }));\n\n  const latestFinishedRaw = jobs.find((job) => job.status !== \"queued\" && job.status !== \"running\") ?? null;\n  const latestFinished = latestFinishedRaw ? enrichJob(latestFinishedRaw, { maxProgressLines }) : null;\n\n  const recent = (options.all ? jobs : jobs.slice(0, maxJobs))\n    .filter((job) => job.status !== \"queued\" && job.status !== \"running\" && job.id !== latestFinished?.id)","sourceCodeStart":192,"sourceCodeEnd":228,"githubUrl":"https://github.com/openai/codex-plugin-cc/blob/db52e28f4d9ded852ab3942cea316258ae4ef346/plugins/codex/scripts/lib/job-control.mjs#L192-L228","documentation":"Thrown by matchJobReference() when the reference does not exactly match any job id AND is not a prefix of any job id (within the predicate-filtered set). It is the catch-all 'reference resolved to nothing' error for that helper. The message points to /codex:status to list known jobs.","triggerScenarios":"Passing a reference string to matchJobReference (via any caller) that matches no job id exactly or by prefix. E.g. a stale id from a previous session, a typo, or an id from a different workspace.","commonSituations":"Using a job id copied from another repo/session; the job file was deleted or rotated out; a typo in the id; the workspace root resolved differently so a different job set was listed.","solutions":["Run /codex:status to see current valid job ids, then retry with a correct id.","Confirm you are in the same repository/workspace where the job was created (resolveWorkspaceRoot).","If the job was archived/rotated, start a new Codex job instead of referencing the old one."],"exampleFix":"// before\nresolveResultJob(cwd, \"zzz999\"); // stale/typo\n\n// after\nconst { running, recent } = buildStatusSnapshot(cwd);\nresolveResultJob(cwd, running[0]?.id ?? recent[0]?.id);","handlingStrategy":"validation","validationCode":"function referenceExists(jobs, reference) {\n  if (!reference) return jobs.length > 0;\n  return jobs.some((j) => j.id === reference || j.id.startsWith(reference));\n}\n\nconst jobs = listJobs(workspaceRoot);\nif (!referenceExists(jobs, ref)) {\n  throw new Error(`Unknown job '${ref}'. Known: ${jobs.map((j) => j.id).slice(0, 5).join(\", \")}...`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  buildSingleJobSnapshot(cwd, ref);\n} catch (err) {\n  if (/No job found/.test(err.message)) {\n    const snap = buildStatusSnapshot(cwd, { all: true });\n    const fallback = snap.running[0] ?? snap.latestFinished ?? snap.recent[0];\n    if (fallback) buildSingleJobSnapshot(cwd, fallback.id);\n    else throw err;\n  } else throw err;\n}","preventionTips":["Always source job ids from a fresh /codex:status call, not memory or another repo.","Confirm the workspace root matches where the job was created.","Treat a 'No job found' as a signal to re-list, not to retry the same id."],"tags":["job-control","not-found","codex"],"backgroundTag":null,"analyzedSha":"db52e28f4d9ded852ab3942cea316258ae4ef346","analyzedAt":"2026-08-13T05:13:20.855Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}