{"record":{"id":"882212eed6dcd0bd","repo":"multica-ai/multica","slug":"a-pending-task-for-this-issue-and-agent-already-ex","errorCode":null,"errorMessage":"a pending task for this issue and agent already exists","messagePattern":"a pending task for this issue and agent already exists","errorType":"http","errorClass":"ErrDuplicatePendingTask","httpStatus":409,"severity":"error","filePath":"server/internal/service/task.go","lineNumber":583,"sourceCode":"// ErrAttributionFailClosed signals that a run resolved to no precise accountable\n// human and the enqueue is REFUSED rather than started. It covers three cases, all\n// of which mean \"we cannot guarantee an accountable human for this run\" (MUL-4302\n// §1/§3.5): the workspace opted into fail-closed; the workspace policy could not be\n// read (so we cannot confirm fallback is allowed — fail closed, don't run); or\n// owner_fallback has no agent owner to fall back to. Enqueue paths surface it so the\n// run never starts.\nvar ErrAttributionFailClosed = errors.New(\"attribution: no precise accountable human and enqueue refused (fail-closed policy, policy read failed, or no agent owner)\")\n\n// ErrDuplicatePendingTask means a fresh enqueue lost the race to a concurrent\n// one: a queued/dispatched task for the same (issue, agent) already exists, so\n// the pending-task unique index rejected the insert (#5914). This is a benign\n// outcome — a sibling run already covers this target\n// — not a server fault. Enqueue paths return it so callers can report a\n// success-shaped coalesced outcome / structured 409 instead of surfacing the\n// raw Postgres constraint as a 500. It is returned BARE (the raw driver text,\n// including the index name, is logged once at debug and never wrapped in) so no\n// upper-layer log or response can leak the constraint name (#5914, Elon review).\nvar ErrDuplicatePendingTask = errors.New(\"a pending task for this issue and agent already exists\")\n\n// isDuplicatePendingTaskErr reports whether err is the pending-task unique-index\n// violation (a concurrent enqueue won the race). Accept both names while v1 and\n// v2 can coexist during a rolling deploy.\nfunc isDuplicatePendingTaskErr(err error) bool {\n\tvar pgErr *pgconn.PgError\n\tif !errors.As(err, &pgErr) || pgErr.Code != \"23505\" {\n\t\treturn false\n\t}\n\tswitch pgErr.ConstraintName {\n\tcase \"idx_one_pending_task_per_issue_agent\", \"idx_one_pending_task_per_issue_agent_v2\":\n\t\treturn true\n\tdefault:\n\t\treturn false\n\t}\n}\n\n// applyAttributionFallback applies the workspace's degraded-attribution policy to a","sourceCodeStart":565,"sourceCodeEnd":601,"githubUrl":"https://github.com/multica-ai/multica/blob/2c0912b6ec764b373d44eeea1e80f0d9f11ab417/server/internal/service/task.go#L565-L601","documentation":"Error \"a pending task for this issue and agent already exists\" thrown in multica-ai/multica.","triggerScenarios":"Thrown at server/internal/service/task.go:583 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Wait for the pending task to finish or cancel it before enqueueing another."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2c0912b6ec764b373d44eeea1e80f0d9f11ab417","analyzedAt":"2026-08-15T13:25:18.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}