{"record":{"id":"a0f11e78562a9c4c","repo":"paperclipai/paperclip","slug":"agent-orgchainhealth-repairguidance-repair","errorCode":null,"errorMessage":"${agent.orgChainHealth?.repairGuidance ?? \"Repair this agent's reporting chain before starting runs\"}","messagePattern":"\\$\\{agent\\.orgChainHealth\\?\\.repairGuidance \\?\\? \"Repair this agent's reporting chain before starting runs\"\\}","errorType":"http","errorClass":null,"httpStatus":409,"severity":"error","filePath":"server/src/routes/agents.ts","lineNumber":4809,"sourceCode":"    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 (hasOwn(req.body as object, \"permissions\")) {\n      res.status(422).json({ error: \"Use /api/agents/:id/permissions for permission changes\" });\n      return;\n    }\n\n    const patchData = { ...(req.body as Record<string, unknown>) };\n    const replaceAdapterConfig = patchData.replaceAdapterConfig === true;\n    delete patchData.replaceAdapterConfig;\n    // The apply-existing flag is not an agent column. The server binds the fixed\n    // reference to the owner stored value with no login round trip. Remove it\n    // from the patch so it never reaches the update values.\n    const applyStoredClaudeLogin = patchData.applyStoredClaudeLogin === true;\n    delete patchData.applyStoredClaudeLogin;\n    if (hasOwn(patchData, \"adapterConfig\")) {\n      const adapterConfig = asRecord(patchData.adapterConfig);\n      if (!adapterConfig) {\n        res.status(422).json({ error: \"adapterConfig must be an object\" });\n        return;\n      }\n      assertNoAgentAdapterConfigMutation(req, adapterConfig);\n      const changingInstructionsConfig = adapterConfigTouchesInstructionsConfig(adapterConfig);\n      if (changingInstructionsConfig) {\n        await assertCanManageInstructionsPath(req, existing);\n      }\n      patchData.adapterConfig = adapterConfig;\n    }\n\n    // Switching an existing agent ONTO another adapter is a new selection, so\n    // it gets the selectable check; keeping the agent's current adapter (even\n    // one since disabled) stays allowed, so a disabled harness does not make an\n    // existing agent uneditable.\n    const nextAdapterType = hasOwn(patchData, \"adapterType\")\n      ? assertKnownAdapterType(patchData.adapterType as string | null | undefined)","sourceCodeStart":4791,"sourceCodeEnd":4827,"githubUrl":"https://github.com/paperclipai/paperclip/blob/01ad8584922b5d85292b1723cae71fa0d9b07a19/server/src/routes/agents.ts#L4791-L4827","documentation":"Org-health conflict guard in the wakeup route helper: a run cannot be started because the agent's reporting chain is invalid (orgChainHealth 'invalid_org_chain'); the 409 carries the agent's specific repair guidance so the operator fixes the chain before running work.","triggerScenarios":"Thrown at server/src/routes/agents.ts:4264 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Repair the agent's reporting chain per the repair guidance, then start runs."],"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"}