{"record":{"id":"a6f1efa895834c5f","repo":"FlowiseAI/Flowise","slug":"error-chatflowscontroller-getchatflowbyapikey-a","errorCode":null,"errorMessage":"Error: chatflowsController.getChatflowByApiKey - apikey not provided!","messagePattern":"Error: chatflowsController\\.getChatflowByApiKey - apikey not provided!","errorType":"exception","errorClass":"InternalFlowiseError","httpStatus":412,"severity":"error","filePath":"packages/server/src/controllers/chatflows/index.ts","lineNumber":111,"sourceCode":"        const { page, limit } = getPageAndLimitParams(req)\n\n        const apiResponse = await chatflowsService.getAllChatflows(\n            req.query?.type as ChatflowType,\n            req.user?.activeWorkspaceId,\n            page,\n            limit\n        )\n        return res.json(apiResponse)\n    } catch (error) {\n        next(error)\n    }\n}\n\n// Get specific chatflow via api key\nconst getChatflowByApiKey = async (req: Request, res: Response, next: NextFunction) => {\n    try {\n        if (typeof req.params === 'undefined' || !req.params.apikey) {\n            throw new InternalFlowiseError(\n                StatusCodes.PRECONDITION_FAILED,\n                `Error: chatflowsController.getChatflowByApiKey - apikey not provided!`\n            )\n        }\n        const apikey = await apiKeyService.getApiKey(req.params.apikey)\n        if (!apikey) {\n            return res.status(401).send('Unauthorized')\n        }\n        const apiResponse = await chatflowsService.getChatflowByApiKey(apikey.id, apikey.workspaceId, req.query.keyonly)\n        return res.json(apiResponse)\n    } catch (error) {\n        next(error)\n    }\n}\n\nconst getChatflowById = async (req: Request, res: Response, next: NextFunction) => {\n    try {\n        if (typeof req.params === 'undefined' || !req.params.id) {","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/server/src/controllers/chatflows/index.ts#L93-L129","documentation":"Thrown by getChatflowByApiKey when req.params.apikey is missing. PRECONDITION_FAILED (412) guard before the API-key lookup. Note this is a public-style endpoint that authenticates via the apikey path param itself, not via req.user.","triggerScenarios":"Calling the by-api-key endpoint with no apikey segment in the URL; client sent the key as a header/query instead of the path param the route expects.","commonSituations":"Client confusion between Authorization header and path-param auth; SDK version changed where the key is passed; URL template uses an undefined variable.","solutions":["Ensure the apikey is in the URL path segment the route expects.","Do not send the apikey only as a header or query — the controller reads req.params.apikey.","Validate the key variable is non-empty client-side before calling."],"exampleFix":"// before\nawait api.get(`/api/v1/chatflows/apikey`)\n// after\nawait api.get(`/api/v1/chatflows/${encodeURIComponent(apikey)}/apikey`)","handlingStrategy":"validation","validationCode":"if (!apikey || typeof apikey !== 'string' || apikey.length === 0) {\n  throw new Error('apikey path param required')\n}","typeGuard":"function isNonEmptyApikey(v: unknown): v is string {\n  return typeof v === 'string' && v.trim().length > 0\n}","tryCatchPattern":null,"preventionTips":["Pass the apikey in the URL path segment the route expects, not only as a header.","URL-encode the apikey when building the path.","Keep auth-by-apikey vs auth-by-JWT endpoints clearly separated in client code."],"tags":["flowise","express","params-validation","precondition","apikey","controller"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}