{"record":{"id":"563aa2d43a0b71fe","repo":"thedotmack/claude-mem","slug":"conflict","errorCode":"Conflict","errorMessage":"Generation job is currently processing; cancel or wait for completion before retrying","messagePattern":"Generation job is currently processing; cancel or wait for completion before retrying","errorType":"http","errorClass":null,"httpStatus":409,"severity":"warning","filePath":"src/server/routes/v1/ServerV1PostgresRoutes.ts","lineNumber":1525,"sourceCode":"      load: (projectId) => repo.getByIdForScope({ id, projectId, teamId }),\n    });\n    if (!current) return null;\n\n    // Idempotent fast-path: already queued -> emit audit only, no DB writes.\n    if (current.status === 'queued') {\n      await this.auditWrite(req, 'generation_job.retried_by_operator', current.id, current.projectId, {\n        outcome: 'noop_already_queued',\n        currentAttempts: current.attempts,\n        requestId: req.requestId ?? null,\n      });\n      return { job: current, retriedCount: extractRetriedCount(current.payload), alreadyQueued: true };\n    }\n\n    if (current.status === 'processing') {\n      // Refuse retry on in-flight jobs — the running worker MUST be allowed\n      // to finish or fail through its normal lifecycle. Operator can wait\n      // or cancel, then retry.\n      res.status(409).json({\n        error: 'Conflict',\n        message: 'Generation job is currently processing; cancel or wait for completion before retrying',\n      });\n      return null;\n    }\n\n    if (current.status === 'completed') {\n      // Refuse retry on already-completed jobs. The deduplication index on\n      // observations (generation_key = job_id + index + content) does NOT\n      // protect against re-running the provider, because LLM output is\n      // non-deterministic and the second run almost always produces a\n      // different content string. Replaying would persist a parallel set\n      // of observations attributed to the same generation_job_id.\n      // cancelGenerationJob applies the same 409 guard for the same reason.\n      res.status(409).json({\n        error: 'Conflict',\n        message: 'Generation job already completed; retrying would duplicate observations',\n      });","sourceCodeStart":1507,"sourceCodeEnd":1543,"githubUrl":"https://github.com/thedotmack/claude-mem/blob/d8bc9755e74915e5c3b999181e10a67c889bce2a/src/server/routes/v1/ServerV1PostgresRoutes.ts#L1507-L1543","documentation":"A 409 Conflict returned when an operator attempts to retry a generation job whose status is 'processing'. The library refuses because the in-flight worker must be allowed to finish or fail through its normal lifecycle; racing it would double-run the provider.","triggerScenarios":"POST to the generation-job retry route for a job whose current.status === 'processing' — i.e. a worker is actively executing the job at the moment of the retry request.","commonSituations":"Operator sees a stuck-looking job and retries while the worker is actually still running; double-clicking a retry button in a dashboard; automation that retries without checking status first.","solutions":["Poll the job status until it transitions to 'completed', 'failed', or 'cancelled' before retrying.","If the job is genuinely hung, cancel it first (cancel endpoint), then retry.","Add a client-side guard that only issues retry when the last-known status is retryable.","Check worker health/logs — long processing may be normal for large payloads."],"exampleFix":"// before\nawait fetch(`/v1/generation-jobs/${id}/retry`, { method: 'POST' });\n// after\nconst job = await (await fetch(`/v1/generation-jobs/${id}`)).json();\nif (job.status === 'processing') await cancelJob(id); // or wait\nawait fetch(`/v1/generation-jobs/${id}/retry`, { method: 'POST' });","handlingStrategy":"validation","validationCode":"const job = await getGenerationJob(id);\nif (job.status === 'processing') throw new Error('job still processing — wait or cancel before retry');","typeGuard":"function isRetryable(status: string): boolean {\n  return ['failed', 'cancelled'].includes(status);\n}","tryCatchPattern":"const res = await retryGenerationJob(id);\nif (res.status === 409) {\n  const body = await res.json();\n  if (body.message.includes('processing')) await pollUntilTerminal(id, thenRetry);\n}","preventionTips":["Check job status immediately before issuing a retry.","Poll until status is terminal (completed/failed/cancelled) before enabling retry UI.","Disable retry buttons while status === 'processing'.","For stuck jobs, cancel first, then retry."],"tags":["http-409","concurrency","state-conflict"],"backgroundTag":"invalid-state-transition","analyzedSha":"d8bc9755e74915e5c3b999181e10a67c889bce2a","analyzedAt":"2026-09-17T16:40:26.182Z","contentChangedAt":"2026-09-17T16:40:26.182Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}