{"record":{"id":"4072485acdf27c65","repo":"paperclipai/paperclip","slug":"existing-orgchainhealth-repairguidance-repa-407248","errorCode":null,"errorMessage":"${existing.orgChainHealth?.repairGuidance ?? \"Repair this agent's reporting chain before clearing its error\"}","messagePattern":"\\$\\{existing\\.orgChainHealth\\?\\.repairGuidance \\?\\? \"Repair this agent's reporting chain before clearing its error\"\\}","errorType":"http","errorClass":null,"httpStatus":409,"severity":"error","filePath":"server/src/routes/agents.ts","lineNumber":4523,"sourceCode":"      }\n      if (actorAgent.role !== \"ceo\") {\n        res.status(403).json({ error: \"Only CEO can manage permissions\" });\n        return;\n      }\n    } else {\n      await assertBoardCanManageAgentsForCompany(req, existing.companyId);\n    }\n\n    const agent = await svc.updatePermissions(id, req.body);\n    if (!agent) {\n      res.status(404).json({ error: \"Agent not found\" });\n      return;\n    }\n\n    const effectiveCanAssignTasks =\n      agent.role === \"ceo\" || Boolean(agent.permissions?.canCreateAgents) || req.body.canAssignTasks;\n    await access.ensureMembership(agent.companyId, \"agent\", agent.id, \"member\", \"active\");\n    await access.setPrincipalPermission(\n      agent.companyId,\n      \"agent\",\n      agent.id,\n      \"tasks:assign\",\n      effectiveCanAssignTasks,\n      req.actor.type === \"board\" ? (req.actor.userId ?? null) : null,\n    );\n\n    const actor = getActorInfo(req);\n    await logActivity(db, {\n      companyId: agent.companyId,\n      actorType: actor.actorType,\n      actorId: actor.actorId,\n      agentId: actor.agentId,\n      runId: actor.runId,\n      agentApiKeyId: actor.agentApiKeyId,\n      action: \"agent.permissions_updated\",\n      entityType: \"agent\",","sourceCodeStart":4505,"sourceCodeEnd":4541,"githubUrl":"https://github.com/paperclipai/paperclip/blob/01ad8584922b5d85292b1723cae71fa0d9b07a19/server/src/routes/agents.ts#L4505-L4541","documentation":"Org-health conflict guard on POST /agents/:id/clear-error: the agent's error state stems from an invalid reporting chain, so clearing the error without repairing the chain would immediately recur; the route returns 409 with the agent-specific repair guidance.","triggerScenarios":"Thrown at server/src/routes/agents.ts:3986 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Repair the agent's reporting chain per the repair guidance, then clear its error."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ad8584922b5d85292b1723cae71fa0d9b07a19","analyzedAt":"2026-08-18T22:49:45.177Z","contentChangedAt":"2026-08-18T22:49:45.177Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}