{"record":{"id":"bb90fcae90a800e9","repo":"paperclipai/paperclip","slug":"key-not-found","errorCode":null,"errorMessage":"Key not found","messagePattern":"Key not found","errorType":"http","errorClass":null,"httpStatus":404,"severity":"error","filePath":"server/src/routes/agents.ts","lineNumber":4753,"sourceCode":"    );\n\n    await logActivity(db, {\n      companyId: existing.companyId,\n      actorType: actor.actorType,\n      actorId: actor.actorId,\n      agentId: actor.agentId,\n      runId: actor.runId,\n      agentApiKeyId: actor.agentApiKeyId,\n      action: \"agent.instructions_file_updated\",\n      entityType: \"agent\",\n      entityId: existing.id,\n      details: {\n        path: result.file.path,\n        size: result.file.size,\n        clearLegacyPromptTemplate: req.body.clearLegacyPromptTemplate === true,\n      },\n    });\n\n    res.json(result.file);\n  });\n\n  router.delete(\"/agents/:id/instructions-bundle/file\", 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    await assertCanManageInstructionsPath(req, existing);\n    assertExternalInstructionsAdmin(req, existing);\n\n    const relativePath = typeof req.query.path === \"string\" ? req.query.path : \"\";\n    if (!relativePath.trim()) {\n      res.status(422).json({ error: \"Query parameter 'path' is required\" });\n      return;\n    }\n\n    const actor = getActorInfo(req);\n    const result = await instructions.deleteFile(existing, relativePath);","sourceCodeStart":4735,"sourceCodeEnd":4771,"githubUrl":"https://github.com/paperclipai/paperclip/blob/01ad8584922b5d85292b1723cae71fa0d9b07a19/server/src/routes/agents.ts#L4735-L4771","documentation":"Ownership guard on DELETE /agents/:id/keys/:keyId: the key id either does not exist or belongs to a different agent than the one in the path, so the revoke is refused with 404 to avoid revoking across agents.","triggerScenarios":"Thrown at server/src/routes/agents.ts:4209 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the key id exists for this agent; list keys and use a valid one."],"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"}