{"record":{"id":"5f2f448fd1e7b8a4","repo":"Mintplex-Labs/anything-llm","slug":"no-valid-api-key-found","errorCode":null,"errorMessage":"No valid api key found.","messagePattern":"No valid api key found\\.","errorType":"http","errorClass":null,"httpStatus":403,"severity":"error","filePath":"server/utils/middleware/validApiKey.js","lineNumber":11,"sourceCode":"const { ApiKey } = require(\"../../models/apiKeys\");\nconst { SystemSettings } = require(\"../../models/systemSettings\");\n\nasync function validApiKey(request, response, next) {\n  const multiUserMode = await SystemSettings.isMultiUserMode();\n  response.locals.multiUserMode = multiUserMode;\n\n  const auth = request.header(\"Authorization\");\n  const bearerKey = auth ? auth.split(\" \")[1] : null;\n  if (!bearerKey) {\n    response.status(403).json({\n      error: \"No valid api key found.\",\n    });\n    return;\n  }\n\n  if (!(await ApiKey.get({ secret: bearerKey }))) {\n    response.status(403).json({\n      error: \"No valid api key found.\",\n    });\n    return;\n  }\n\n  next();\n}\n\nmodule.exports = {\n  validApiKey,\n};","sourceCodeStart":1,"sourceCodeEnd":29,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/3aec848f2885144aa8f1e53b9731a04310d5d558/server/utils/middleware/validApiKey.js#L1-L29","documentation":"Auth guard in the validApiKey middleware: the Authorization header is missing or contains no bearer token, so there is no API key to validate against the ApiKey table and the request is refused with 403.","triggerScenarios":"API request made without a valid API key. Triggered when validApiKey middleware finds no matching key in the Authorization header (validApiKey.js:11).","commonSituations":"See trigger scenarios.","solutions":["Send the API key as a Bearer token in the Authorization header: 'Authorization: Bearer <key>'.","Generate a valid API key in the AnythingLLM API keys settings and use that key.","Check the key was not revoked or deleted."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3aec848f2885144aa8f1e53b9731a04310d5d558","analyzedAt":"2026-08-18T10:02:21.017Z","contentChangedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}