FlowiseAI/Flowise · warning · InternalFlowiseError

Error: apikeyController.updateApiKey - id not provided!

Error message

Error: apikeyController.updateApiKey - id not provided!

What it means

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.

Source

Thrown at packages/server/src/controllers/apikey/index.ts:52

        ) {
            throw new InternalFlowiseError(
                StatusCodes.PRECONDITION_FAILED,
                `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)

View on GitHub (pinned to abe4a8601a)

Solutions

  1. Include the API key ID in the request path, e.g. PUT /api/v1/apikeys/:id with a real id value.
  2. Verify the client uses the current route definition after any API path changes.
  3. Ensure the route is registered with the :id param in the Express router.
  4. Return the missing-param name to the client for faster debugging.

Example fix

// before
if (typeof req.params === 'undefined' || !req.params.id) {
    throw new InternalFlowiseError(StatusCodes.PRECONDITION_FAILED, `Error: apikeyController.updateApiKey - id not provided!`)
}

// after
if (!req.params?.id) {
    throw new InternalFlowiseError(StatusCodes.BAD_REQUEST, 'API key id is required in the URL path')
}
Defensive patterns

Strategy: validation

Validate before calling

function requireKeyId(params: any): asserts params is { id: string } {
    if (!params || typeof params.id !== 'string' || !params.id) {
        throw new InternalFlowiseError(StatusCodes.BAD_REQUEST, 'API key id is required in the URL path')
    }
}
requireKeyId(req.params)

Type guard

function hasKeyId(params: unknown): params is { id: string } {
    return typeof (params as any)?.id === 'string' && (params as any).id.length > 0
}

Try / catch

// Relies on the global error handler mapping InternalFlowiseError.statusCode (412) to HTTP.

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of FlowiseAI/Flowise@abe4a8601a (2026-08-12). Data as JSON: /api/errors/ba8580105a004675. Report an issue: GitHub.