{"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":4014,"sourceCode":"        title: agentsTable.title,\n        status: agentsTable.status,\n        adapterType: agentsTable.adapterType,\n        runtimeConfig: agentsTable.runtimeConfig,\n        lastHeartbeatAt: agentsTable.lastHeartbeatAt,\n        companyName: companies.name,\n        companyIssuePrefix: companies.issuePrefix,\n      })\n      .from(agentsTable)\n      .innerJoin(companies, eq(agentsTable.companyId, companies.id))\n      .orderBy(companies.name, agentsTable.name);\n\n    const items: InstanceSchedulerHeartbeatAgent[] = rows\n      .map((row) => {\n        const policy = parseSchedulerHeartbeatPolicy(row.runtimeConfig);\n        const statusEligible =\n          row.status !== \"paused\" &&\n          row.status !== \"terminated\" &&\n          row.status !== \"pending_approval\";\n\n        return {\n          id: row.id,\n          companyId: row.companyId,\n          companyName: row.companyName,\n          companyIssuePrefix: row.companyIssuePrefix,\n          agentName: row.agentName,\n          agentUrlKey: deriveAgentUrlKey(row.agentName, row.id),\n          role: row.role as InstanceSchedulerHeartbeatAgent[\"role\"],\n          title: row.title,\n          status: row.status as InstanceSchedulerHeartbeatAgent[\"status\"],\n          adapterType: row.adapterType,\n          intervalSec: policy.intervalSec,\n          heartbeatEnabled: policy.enabled,\n          schedulerActive: statusEligible && policy.enabled && policy.intervalSec > 0,\n          lastHeartbeatAt: row.lastHeartbeatAt,\n        };\n      })","sourceCodeStart":3996,"sourceCodeEnd":4032,"githubUrl":"https://github.com/paperclipai/paperclip/blob/3f1d897a7c018d76563a21c6e39c3c9b03933622/server/src/routes/agents.ts#L3996-L4032","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":"3f1d897a7c018d76563a21c6e39c3c9b03933622","analyzedAt":"2026-08-18T22:49:45.177Z","contentChangedAt":"2026-08-18T22:49:45.177Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}