{"record":{"id":"ba8580105a004675","repo":"FlowiseAI/Flowise","slug":"error-apikeycontroller-updateapikey-id-not-prov","errorCode":null,"errorMessage":"Error: apikeyController.updateApiKey - id not provided!","messagePattern":"Error: apikeyController\\.updateApiKey - id not provided!","errorType":"validation","errorClass":"InternalFlowiseError","httpStatus":412,"severity":"warning","filePath":"packages/server/src/controllers/apikey/index.ts","lineNumber":52,"sourceCode":"        ) {\n            throw new InternalFlowiseError(\n                StatusCodes.PRECONDITION_FAILED,\n                `Error: apikeyController.createApiKey - permissions must be an array of strings!`\n            )\n        }\n        const user = req.user as LoggedInUser\n        const apiResponse = await apikeyService.createApiKey(user, req.body.keyName, req.body.permissions)\n        return res.json(apiResponse)\n    } catch (error) {\n        next(error)\n    }\n}\n\n// Update api key\nconst updateApiKey = async (req: Request, res: Response, next: NextFunction) => {\n    try {\n        if (typeof req.params === 'undefined' || !req.params.id) {\n            throw new InternalFlowiseError(StatusCodes.PRECONDITION_FAILED, `Error: apikeyController.updateApiKey - id not provided!`)\n        }\n        if (typeof req.body === 'undefined' || !req.body.keyName) {\n            throw new InternalFlowiseError(StatusCodes.PRECONDITION_FAILED, `Error: apikeyController.updateApiKey - keyName not provided!`)\n        }\n        if (\n            !req.body.permissions ||\n            !Array.isArray(req.body.permissions) ||\n            req.body.permissions.length === 0 ||\n            !req.body.permissions.every((p: any) => typeof p === 'string')\n        ) {\n            throw new InternalFlowiseError(\n                StatusCodes.PRECONDITION_FAILED,\n                `Error: apikeyController.updateApiKey - permissions must be an array of strings!`\n            )\n        }\n        const user = req.user as LoggedInUser\n        const apiResponse = await apikeyService.updateApiKey(user, req.params.id, req.body.keyName, req.body.permissions)\n        return res.json(apiResponse)","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/server/src/controllers/apikey/index.ts#L34-L70","documentation":"updateApiKey handler first checks that req.params.id is present; if req.params is undefined or id is missing/empty, it throws InternalFlowiseError 412. The id identifies which API key to update, so a missing route parameter cannot proceed. This guard runs before body validation.","triggerScenarios":"PUT/PATCH to the update-api-key route without the :id path segment, or with an empty id. Happens when the route is misconfigured, the client hits the wrong URL, or the path param is stripped.","commonSituations":"Client calls the base URL without appending the key ID. Route definition changed and the client wasn't updated. URL template bug dropping the id. Test request missing the path param.","solutions":["Include the API key ID in the request path, e.g. PUT /api/v1/apikeys/:id with a real id value.","Verify the client uses the current route definition after any API path changes.","Ensure the route is registered with the :id param in the Express router.","Return the missing-param name to the client for faster debugging."],"exampleFix":"// before\nif (typeof req.params === 'undefined' || !req.params.id) {\n    throw new InternalFlowiseError(StatusCodes.PRECONDITION_FAILED, `Error: apikeyController.updateApiKey - id not provided!`)\n}\n\n// after\nif (!req.params?.id) {\n    throw new InternalFlowiseError(StatusCodes.BAD_REQUEST, 'API key id is required in the URL path')\n}","handlingStrategy":"validation","validationCode":"function requireKeyId(params: any): asserts params is { id: string } {\n    if (!params || typeof params.id !== 'string' || !params.id) {\n        throw new InternalFlowiseError(StatusCodes.BAD_REQUEST, 'API key id is required in the URL path')\n    }\n}\nrequireKeyId(req.params)","typeGuard":"function hasKeyId(params: unknown): params is { id: string } {\n    return typeof (params as any)?.id === 'string' && (params as any).id.length > 0\n}","tryCatchPattern":"// Relies on the global error handler mapping InternalFlowiseError.statusCode (412) to HTTP.","preventionTips":["Include the API key ID in the request path (PUT /api/v1/apikeys/:id).","Keep the client URL template in sync with the server route definition.","Register the route with the :id param in the Express router.","Return the missing-param name to the client for faster debugging."],"tags":["validation","controller","apikey","input-validation","route-params","express"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}