FlowiseAI/Flowise · error · InternalFlowiseError

Error: chatflowsController.saveChatflow - workspace ${worksp

Error message

Error: chatflowsController.saveChatflow - workspace ${workspaceId} not found!

What it means

Thrown by saveChatflow when req.user?.activeWorkspaceId is absent (after org check). Returns 404 NOT_FOUND — misleading; the user context is incomplete, no record is being searched. The chatflow is only created once all three (body, orgId, workspaceId) are present.

Source

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

        next(error)
    }
}

const saveChatflow = async (req: Request, res: Response, next: NextFunction) => {
    try {
        if (!req.body) {
            throw new InternalFlowiseError(StatusCodes.PRECONDITION_FAILED, `Error: chatflowsController.saveChatflow - body not provided!`)
        }
        const orgId = req.user?.activeOrganizationId
        if (!orgId) {
            throw new InternalFlowiseError(
                StatusCodes.NOT_FOUND,
                `Error: chatflowsController.saveChatflow - organization ${orgId} not found!`
            )
        }
        const workspaceId = req.user?.activeWorkspaceId
        if (!workspaceId) {
            throw new InternalFlowiseError(
                StatusCodes.NOT_FOUND,
                `Error: chatflowsController.saveChatflow - workspace ${workspaceId} not found!`
            )
        }
        const subscriptionId = req.user?.activeOrganizationSubscriptionId || ''
        const body = req.body

        const existingChatflowCount = await chatflowsService.getAllChatflowsCountByOrganization(body.type, orgId)
        const newChatflowCount = 1
        await checkUsageLimit('flows', subscriptionId, getRunningExpressApp().usageCacheManager, existingChatflowCount + newChatflowCount)

        const newChatFlow = new ChatFlow()
        Object.assign(newChatFlow, stripProtectedFields(body))

        newChatFlow.workspaceId = workspaceId
        const apiResponse = await chatflowsService.saveChatflow(
            newChatFlow,
            orgId,

View on GitHub (pinned to abe4a8601a)

Solutions

  1. Confirm the user has a workspace membership row.
  2. Run the workspace selection flow after login.
  3. Ensure auth middleware injecting activeWorkspaceId runs on the route.
  4. Decode the token and verify the workspace claim.

Example fix

// before: no workspace claim
// after: select workspace then create
await api.post('/workspaces/select', { workspaceId })
await api.post('/api/v1/chatflows', payload)
Defensive patterns

Strategy: validation

Validate before calling

function hasWorkspaceClaim(user): boolean {
  return Boolean(user && (user as any).activeWorkspaceId)
}
if (!hasWorkspaceClaim(currentUser)) {
  // run workspace selection before saving
}

Type guard

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

Prevention

When it happens

Trigger: Authenticated POST with body and org claim but no activeWorkspaceId. User is in an org but has not selected/been assigned a workspace.

Common situations: Workspace membership missing; client skipped workspace selection; workspace-resolving middleware did not run; stale token.

Related errors


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