{"record":{"id":"15559ed2127f7698","repo":"Mintplex-Labs/anything-llm","slug":"could-not-find-an-api-key","errorCode":null,"errorMessage":"Could not find an API Key.","messagePattern":"Could not find an API Key\\.","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"server/endpoints/system.js","lineNumber":1049,"sourceCode":"    }\n  );\n\n  app.get(\"/system/api-keys\", [validatedRequest], async (_, response) => {\n    try {\n      if (response.locals.multiUserMode) {\n        return response.sendStatus(401).end();\n      }\n\n      const apiKeys = await ApiKey.where({});\n      return response.status(200).json({\n        apiKeys,\n        error: null,\n      });\n    } catch (error) {\n      console.error(error);\n      response.status(500).json({\n        apiKey: null,\n        error: \"Could not find an API Key.\",\n      });\n    }\n  });\n\n  app.post(\n    \"/system/generate-api-key\",\n    [validatedRequest],\n    async (request, response) => {\n      try {\n        if (response.locals.multiUserMode) {\n          return response.sendStatus(401).end();\n        }\n\n        const { name = null } = reqBody(request);\n        const { apiKey, error } = await ApiKey.create(null, name);\n        await EventLogs.logEvent(\n          \"api_key_created\",\n          { name: apiKey?.name },","sourceCodeStart":1031,"sourceCodeEnd":1067,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/20f6d3546c1938bfea1ad304f58a592dddcc5948/server/endpoints/system.js#L1031-L1067","documentation":"Catch block of GET /system/api-keys: querying ApiKey.where({}) threw (typically a database failure), so the endpoint responds 500 with this error string and a null apiKey. Also unreachable in multi-user mode, which is blocked earlier with 401.","triggerScenarios":"Thrown at server/endpoints/system.js:1035 when the library encounters an invalid state.","commonSituations":"Referencing an API key that does not exist.","solutions":["Verify the API key ID exists before operating on it.","List API keys and use a valid ID."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"20f6d3546c1938bfea1ad304f58a592dddcc5948","analyzedAt":"2026-08-18T10:02:21.017Z","contentChangedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}