FlowiseAI/Flowise · error · InternalFlowiseError

Error: chatflowsController.deleteChatflow - organization ${o

Error message

Error: chatflowsController.deleteChatflow - organization ${orgId} not found!

What it means

Thrown by deleteChatflow when req.user?.activeOrganizationId is absent, after the id check passed. Returns NOT_FOUND (404) — a misleading code, since the missing value is an auth-context field, not a missing resource. Indicates the user's session/token lacks an org claim.

Source

Thrown at packages/server/src/controllers/chatflows/index.ts:57

                StatusCodes.PRECONDITION_FAILED,
                `Error: chatflowsController.checkIfChatflowIsValidForUploads - id not provided!`
            )
        }
        const apiResponse = await chatflowsService.checkIfChatflowIsValidForUploads(req.params.id)
        return res.json(apiResponse)
    } catch (error) {
        next(error)
    }
}

const deleteChatflow = async (req: Request, res: Response, next: NextFunction) => {
    try {
        if (typeof req.params === 'undefined' || !req.params.id) {
            throw new InternalFlowiseError(StatusCodes.PRECONDITION_FAILED, `Error: chatflowsController.deleteChatflow - id not provided!`)
        }
        const orgId = req.user?.activeOrganizationId
        if (!orgId) {
            throw new InternalFlowiseError(
                StatusCodes.NOT_FOUND,
                `Error: chatflowsController.deleteChatflow - organization ${orgId} not found!`
            )
        }
        const workspaceId = req.user?.activeWorkspaceId
        if (!workspaceId) {
            throw new InternalFlowiseError(
                StatusCodes.NOT_FOUND,
                `Error: chatflowsController.deleteChatflow - workspace ${workspaceId} not found!`
            )
        }
        const userPermittedTypes: EnumChatflowType[] = []
        const permissions = req.user!.permissions
        if (req.user?.isOrganizationAdmin) {
            userPermittedTypes.push(EnumChatflowType.CHATFLOW)
            userPermittedTypes.push(EnumChatflowType.AGENTFLOW)
            userPermittedTypes.push(EnumChatflowType.MULTIAGENT)
            userPermittedTypes.push(EnumChatflowType.ASSISTANT)

View on GitHub (pinned to abe4a8601a)

Solutions

  1. Decode the caller's JWT and confirm activeOrganizationId is present and valid.
  2. Ensure the user has at least one organization membership; create/assign one if not.
  3. Verify auth middleware populating activeOrganizationId runs on this route before the controller.
  4. Force a re-login / token refresh after org assignment.
  5. Note: status code should arguably be 401/403, not 404 — file an upstream issue.

Example fix

// before: token has no org claim
// after: ensure user is in an org, then re-issue token
await api.post('/auth/login', creds) // token now contains activeOrganizationId
await api.delete(`/api/v1/chatflows/${id}`)
Defensive patterns

Strategy: validation

Validate before calling

function hasOrgClaim(user): boolean {
  return Boolean(user && (user as any).activeOrganizationId)
}
if (!hasOrgClaim(currentUser)) {
  // ensure org membership / re-login instead of calling delete
}

Type guard

function hasOrgContext(u: unknown): u is { activeOrganizationId: string } {
  return typeof u === 'object' && u !== null
    && typeof (u as any).activeOrganizationId === 'string' && (u as any).activeOrganizationId.length > 0
}

Prevention

When it happens

Trigger: Authenticated DELETE /api/v1/chatflows/:id where the JWT/session has no activeOrganizationId. Common right after signup before org assignment, or with a token minted pre-multitenancy.

Common situations: User account exists but has no organization membership; auth middleware that injects activeOrganizationId did not run or failed silently; legacy token without org claim still in use; test stub omits the field.

Related errors


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