{"record":{"id":"4c8c6abd02923e47","repo":"paperclipai/paperclip","slug":"evaluation-issue-not-found","errorCode":"evaluation_issue_not_found","errorMessage":"Evaluation issue not found","messagePattern":"Evaluation issue not found","errorType":"error_code","errorClass":"WatchdogDecisionApplicationError","httpStatus":null,"severity":"error","filePath":"server/src/modules/active-run-watchdog/application/use-cases.ts","lineNumber":143,"sourceCode":"  evaluationIssueId?: string | null;\n  reason?: string | null;\n  snoozedUntil?: Date | null;\n  createdByRunId?: string | null;\n  now?: Date;\n};\n\nexport function createRecordWatchdogDecision(deps: RecordWatchdogDecisionDeps) {\n  return async function recordWatchdogDecision(\n    input: RecordWatchdogDecisionUseCaseInput,\n  ): Promise<WatchdogDecisionRecord> {\n    const run = await deps.reader.findRunForCompany(input.companyId, input.runId);\n    if (!run) throw new WatchdogDecisionApplicationError(\"run_not_found\", \"Heartbeat run not found\");\n\n    const evaluationIssue = input.evaluationIssueId\n      ? await deps.reader.findEvaluationIssueById(input.companyId, input.evaluationIssueId)\n      : null;\n    if (input.evaluationIssueId && !evaluationIssue) {\n      throw new WatchdogDecisionApplicationError(\"evaluation_issue_not_found\", \"Evaluation issue not found\");\n    }\n    if (input.actor.type === \"agent\" && !evaluationIssue) {\n      throw new WatchdogDecisionApplicationError(\n        \"evaluation_issue_required\",\n        \"Agent watchdog decisions require the target evaluation issue\",\n      );\n    }\n\n    const boardActor = input.actor.type === \"board\";\n    const assignedRecoveryOwner =\n      input.actor.type === \"agent\" &&\n      Boolean(input.actor.agentId) &&\n      evaluationIssue !== null &&\n      evaluationIssue.originKind === STALE_ACTIVE_RUN_EVALUATION_ORIGIN_KIND &&\n      evaluationIssue.originId === run.id &&\n      evaluationIssue.hiddenAt === null &&\n      ![\"done\", \"cancelled\"].includes(evaluationIssue.status) &&\n      evaluationIssue.assigneeAgentId === input.actor.agentId;","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/paperclipai/paperclip/blob/01ad8584922b5d85292b1723cae71fa0d9b07a19/server/src/modules/active-run-watchdog/application/use-cases.ts#L125-L161","documentation":"When input.evaluationIssueId is supplied, createRecordWatchdogDecision fetches it company-scoped via findEvaluationIssueById; if the ID was provided but no issue is found, it throws WatchdogDecisionApplicationError with code evaluation_issue_not_found. This guards against recording decisions referencing evaluation issues that don't exist or belong to another company.","triggerScenarios":"recordWatchdogDecision called with a non-null evaluationIssueId that resolves to no issue within input.companyId — wrong ID, deleted/hidden issue outside query filters, or an ID from a different company.","commonSituations":"Stale issue IDs cached in a UI after the issue was deleted; copying issue IDs between company environments; typos in IDs from API logs; agent scripts replaying old decision payloads.","solutions":["Verify the evaluation issue ID exists and belongs to the same company via the issues API or DB query","Refresh the issue ID from the stale-active-run evaluation issue list before recording the decision","If the ID was optional in your flow, omit evaluationIssueId rather than passing an invalid value (but note agents must supply a valid one)","Check whether the issue was hidden or moved, making the scoped lookup miss it"],"exampleFix":"// before\nawait recordWatchdogDecision({ companyId, runId, evaluationIssueId: staleIssueId, ... });\n// after\nconst issue = await getEvaluationIssue(companyId, issueId);\nif (!issue) { throw new Error('evaluation issue missing; refetch from issues list'); }\nawait recordWatchdogDecision({ companyId, runId, evaluationIssueId: issue.id, ... });","handlingStrategy":"validation","validationCode":"const issue = await getEvaluationIssue(companyId, evaluationIssueId); if (!issue) throw new Error(`evaluation issue ${evaluationIssueId} not found in company ${companyId}`);","typeGuard":"null","tryCatchPattern":"try { await recordWatchdogDecision(input); } catch (e) { if (e.code === 'evaluation_issue_not_found') { /* refetch issue from issues list; drop stale payloads */ } else throw e; }","preventionTips":["Refresh evaluation issue IDs from the API right before recording decisions","Purge stale issue references from UI caches after deletes","Never copy issue IDs between company environments","For agents, always source evaluationIssueId from the assigned stale-active-run evaluation issue"],"tags":["not-found","watchdog","issues","company-scope"],"backgroundTag":"entity-not-found","analyzedSha":"01ad8584922b5d85292b1723cae71fa0d9b07a19","analyzedAt":"2026-09-10T03:14:50.855Z","contentChangedAt":"2026-09-10T03:14:50.855Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}