{"record":{"id":"d7b41abcb80ab6b2","repo":"paperclipai/paperclip","slug":"only-pending-approval-agents-can-be-approved","errorCode":null,"errorMessage":"Only pending approval agents can be approved","messagePattern":"Only pending approval agents can be approved","errorType":"http","errorClass":null,"httpStatus":409,"severity":"error","filePath":"server/src/routes/agents.ts","lineNumber":4555,"sourceCode":"      agentId: actor.agentId,\n      runId: actor.runId,\n      agentApiKeyId: actor.agentApiKeyId,\n      action: \"agent.permissions_updated\",\n      entityType: \"agent\",\n      entityId: agent.id,\n      details: {\n        canCreateAgents: agent.permissions?.canCreateAgents ?? false,\n        canCreateSkills: agent.permissions?.canCreateSkills ?? true,\n        canAssignTasks: effectiveCanAssignTasks,\n        trustPreset: agent.permissions?.trustPreset ?? \"standard\",\n      },\n    });\n\n    res.json(await buildAgentDetail(agent));\n  });\n\n  router.patch(\"/agents/:id/instructions-path\", validate(updateAgentInstructionsPathSchema), async (req, res) => {\n    if (req.actor.type !== \"board\") {\n      throw forbidden(\"Only board-authenticated callers can manage instructions path or bundle configuration\");\n    }\n\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    await assertCanManageInstructionsPath(req, existing);\n    assertExternalInstructionsAdmin(req, existing);\n\n    const existingAdapterConfig = asRecord(existing.adapterConfig) ?? {};\n    const explicitKey = asNonEmptyString(req.body.adapterConfigKey);\n    const defaultKey = resolveInstructionsPathKey(existing.adapterType);\n    const adapterConfigKey = explicitKey ?? defaultKey;\n    if (!adapterConfigKey) {\n      res.status(422).json({\n        error: `No default instructions path key for adapter type '${existing.adapterType}'. Provide adapterConfigKey.`,\n      });","sourceCodeStart":4537,"sourceCodeEnd":4573,"githubUrl":"https://github.com/paperclipai/paperclip/blob/01ad8584922b5d85292b1723cae71fa0d9b07a19/server/src/routes/agents.ts#L4537-L4573","documentation":"State-machine guard on POST /agents/:id/approve: approval links only apply to agents in 'pending_approval' status, but this agent is in another lifecycle state (already active, paused, etc.), so the approve action is rejected with 409.","triggerScenarios":"Thrown at server/src/routes/agents.ts:4018 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Only approve agents whose status is pending approval; check the agent's current status first."],"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"}