{"record":{"id":"a7ef29192e686dcd","repo":"paperclipai/paperclip","slug":"existing-orgchainhealth-repairguidance-repa","errorCode":null,"errorMessage":"${existing.orgChainHealth?.repairGuidance ?? \"Repair this agent's reporting chain before resuming it\"}","messagePattern":"\\$\\{existing\\.orgChainHealth\\?\\.repairGuidance \\?\\? \"Repair this agent's reporting chain before resuming it\"\\}","errorType":"http","errorClass":null,"httpStatus":409,"severity":"error","filePath":"server/src/routes/agents.ts","lineNumber":3883,"sourceCode":"      agent.id,\n      req.actor.type === \"board\" ? (req.actor.userId ?? null) : null,\n    );\n    await builtInAgentService(db).ensureCompanyDefaultAgentGrants(companyId);\n\n    if (agent.budgetMonthlyCents > 0) {\n      await budgets.upsertPolicy(\n        companyId,\n        {\n          scopeType: \"agent\",\n          scopeId: agent.id,\n          amount: agent.budgetMonthlyCents,\n          windowKind: \"calendar_month_utc\",\n        },\n        actor.actorType === \"user\" ? actor.actorId : null,\n      );\n    }\n\n    res.status(201).json(agent);\n  });\n\n  router.patch(\"/agents/:id/permissions\", validate(updateAgentPermissionsSchema), async (req, res) => {\n    const id = req.params.id as string;\n    const existing = await getAccessibleResource(req, res, svc.getById(id), \"Agent not found\");\n    if (!existing) return;\n\n    if (req.actor.type === \"agent\") {\n      const actorAgent = req.actor.agentId ? await svc.getById(req.actor.agentId) : null;\n      if (!actorAgent || actorAgent.companyId !== existing.companyId) {\n        res.status(403).json({ error: \"Forbidden\" });\n        return;\n      }\n      if (actorAgent.role !== \"ceo\") {\n        res.status(403).json({ error: \"Only CEO can manage permissions\" });\n        return;\n      }\n    } else {","sourceCodeStart":3865,"sourceCodeEnd":3901,"githubUrl":"https://github.com/paperclipai/paperclip/blob/5716fe907e596ce73501408fc6efdb19fb61edf2/server/src/routes/agents.ts#L3865-L3901","documentation":"Org-health conflict guard on POST /agents/:id/resume: the agent's reporting chain is currently invalid (orgChainHealth status 'invalid_org_chain' — e.g. its manager no longer exists), so resuming is blocked with 409 and the agent-specific repair guidance text is returned.","triggerScenarios":"Thrown at server/src/routes/agents.ts:3955 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Repair the agent's reporting chain per the repair guidance, then resume the agent."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5716fe907e596ce73501408fc6efdb19fb61edf2","analyzedAt":"2026-08-18T22:49:45.177Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}