{"record":{"id":"d1c407e6d6066eec","repo":"paperclipai/paperclip","slug":"use-api-agents-id-permissions-for-permission-cha","errorCode":null,"errorMessage":"Use /api/agents/:id/permissions for permission changes","messagePattern":"Use /api/agents/:id/permissions for permission changes","errorType":"http","errorClass":null,"httpStatus":422,"severity":"error","filePath":"server/src/routes/agents.ts","lineNumber":3687,"sourceCode":"          metadata: requestedMetadata,\n          agentId: agent.id,\n          requestedByAgentId: actor.actorType === \"agent\" ? actor.actorId : null,\n          requestedConfigurationSnapshot: {\n            adapterType: requestedAdapterType,\n            adapterConfig: requestedAdapterConfig,\n            runtimeConfig: requestedRuntimeConfig,\n            desiredSkills: desiredSkillAssignment.desiredSkills,\n          },\n        },\n        decisionNote: null,\n        decidedByUserId: null,\n        decidedAt: null,\n        updatedAt: new Date(),\n      });\n\n      if (sourceIssueIds.length > 0) {\n        await issueApprovalsSvc.linkManyForApproval(approval.id, sourceIssueIds, {\n          agentId: actor.actorType === \"agent\" ? actor.actorId : null,\n          userId: actor.actorType === \"user\" ? actor.actorId : null,\n        });\n      }\n    }\n\n    await logActivity(db, {\n      companyId,\n      actorType: actor.actorType,\n      actorId: actor.actorId,\n      agentId: actor.agentId,\n      runId: actor.runId,\n      agentApiKeyId: actor.agentApiKeyId,\n      action: \"agent.hire_created\",\n      entityType: \"agent\",\n      entityId: agent.id,\n      details: {\n        name: agent.name,\n        role: agent.role,","sourceCodeStart":3669,"sourceCodeEnd":3705,"githubUrl":"https://github.com/paperclipai/paperclip/blob/5716fe907e596ce73501408fc6efdb19fb61edf2/server/src/routes/agents.ts#L3669-L3705","documentation":"Contract guard on PATCH /agents/:id: the request body contains a 'permissions' key, but permissions must be changed through the dedicated permission endpoint (with its own authorization rules), so the general update route rejects the body with 422.","triggerScenarios":"Thrown at server/src/routes/agents.ts:3754 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use the /api/agents/:id/permissions endpoint for permission changes instead of this route."],"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-14T05:17:10.506Z"}