FlowiseAI/Flowise · warning · InternalFlowiseError
Error: apikeyController.updateApiKey - keyName not provided!
Error message
Error: apikeyController.updateApiKey - keyName not provided!
What it means
updateApiKey handler checks, after the id guard, that req.body.keyName is truthy; if req.body is undefined or keyName is missing/empty, it throws InternalFlowiseError 412. The update service requires a new keyName to apply, so an absent name cannot proceed.
Source
Thrown at packages/server/src/controllers/apikey/index.ts:55
`Error: apikeyController.createApiKey - permissions must be an array of strings!`
)
}
const user = req.user as LoggedInUser
const apiResponse = await apikeyService.createApiKey(user, req.body.keyName, req.body.permissions)
return res.json(apiResponse)
} catch (error) {
next(error)
}
}
// Update api key
const updateApiKey = async (req: Request, res: Response, next: NextFunction) => {
try {
if (typeof req.params === 'undefined' || !req.params.id) {
throw new InternalFlowiseError(StatusCodes.PRECONDITION_FAILED, `Error: apikeyController.updateApiKey - id not provided!`)
}
if (typeof req.body === 'undefined' || !req.body.keyName) {
throw new InternalFlowiseError(StatusCodes.PRECONDITION_FAILED, `Error: apikeyController.updateApiKey - keyName not provided!`)
}
if (
!req.body.permissions ||
!Array.isArray(req.body.permissions) ||
req.body.permissions.length === 0 ||
!req.body.permissions.every((p: any) => typeof p === 'string')
) {
throw new InternalFlowiseError(
StatusCodes.PRECONDITION_FAILED,
`Error: apikeyController.updateApiKey - permissions must be an array of strings!`
)
}
const user = req.user as LoggedInUser
const apiResponse = await apikeyService.updateApiKey(user, req.params.id, req.body.keyName, req.body.permissions)
return res.json(apiResponse)
} catch (error) {
next(error)
}View on GitHub (pinned to abe4a8601a)
Solutions
- Include a non-empty 'keyName' string in the JSON body of the update request.
- Pre-fill the form with the current name so an empty submit can't happen.
- Ensure express.json() middleware is active so req.body is parsed.
- If partial updates are intended, make keyName optional in the service and skip the check when absent.
Example fix
// before
if (typeof req.body === 'undefined' || !req.body.keyName) {
throw new InternalFlowiseError(StatusCodes.PRECONDITION_FAILED, `Error: apikeyController.updateApiKey - keyName not provided!`)
}
// after
if (!req.body?.keyName || typeof req.body.keyName !== 'string') {
throw new InternalFlowiseError(StatusCodes.BAD_REQUEST, 'keyName is required and must be a non-empty string')
} Defensive patterns
Strategy: validation
Validate before calling
function requireKeyName(body: any): asserts body is { keyName: string } {
if (!body || typeof body.keyName !== 'string' || !body.keyName) {
throw new InternalFlowiseError(StatusCodes.BAD_REQUEST, 'keyName is required')
}
}
requireKeyName(req.body) Type guard
function hasKeyName(body: unknown): body is { keyName: string } {
return typeof (body as any)?.keyName === 'string' && (body as any).keyName.length > 0
} Try / catch
// Relies on the global error handler mapping InternalFlowiseError.statusCode (412) to HTTP.
Prevention
- Include a non-empty 'keyName' string in the update body.
- Pre-fill the form with the current name so submits aren't blank.
- Ensure express.json() is mounted so req.body is defined.
- If partial updates are intended, make keyName optional and skip the check when absent.
When it happens
Trigger: PUT/PATCH to update-api-key with a valid id in the path but a body missing keyName (omitted, empty, or null), or no body at all.
Common situations: Client sends only permissions in the update body, forgetting keyName. Form submitted with a blank name field. Body-parsing middleware not mounted so req.body is undefined.
Related errors
- Error: apikeyController.createApiKey - keyName not provided!
- Error: apikeyController.createApiKey - permissions must be a
- Error: apikeyController.updateApiKey - id not provided!
- Error: apikeyController.updateApiKey - permissions must be a
- Question and selectedChatModel are required
AI-assisted analysis of FlowiseAI/Flowise@abe4a8601a (2026-08-12).
Data as JSON: /api/errors/ef4d7a9ed30e7672.
Report an issue: GitHub.