FlowiseAI/Flowise · error · InternalFlowiseError

Error: chatflowsController.getChatflowById - workspace ${wor

Error message

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

What it means

Thrown by getChatflowById when req.user?.activeWorkspaceId is absent (after the id check passed). Returns 404 NOT_FOUND — misleading, since the issue is missing workspace context, not a missing chatflow. The chatflow lookup only runs once activeWorkspaceId is present.

Source

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

        const apikey = await apiKeyService.getApiKey(req.params.apikey)
        if (!apikey) {
            return res.status(401).send('Unauthorized')
        }
        const apiResponse = await chatflowsService.getChatflowByApiKey(apikey.id, apikey.workspaceId, req.query.keyonly)
        return res.json(apiResponse)
    } catch (error) {
        next(error)
    }
}

const getChatflowById = async (req: Request, res: Response, next: NextFunction) => {
    try {
        if (typeof req.params === 'undefined' || !req.params.id) {
            throw new InternalFlowiseError(StatusCodes.PRECONDITION_FAILED, `Error: chatflowsController.getChatflowById - id not provided!`)
        }
        const workspaceId = req.user?.activeWorkspaceId
        if (!workspaceId) {
            throw new InternalFlowiseError(
                StatusCodes.NOT_FOUND,
                `Error: chatflowsController.getChatflowById - workspace ${workspaceId} not found!`
            )
        }
        const apiResponse = await chatflowsService.getChatflowById(req.params.id, workspaceId)
        return res.json(apiResponse)
    } catch (error) {
        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) {

View on GitHub (pinned to abe4a8601a)

Solutions

  1. Verify the user has a workspace membership and the active workspace claim is in the token.
  2. Run workspace selection/switch flow after login.
  3. Ensure auth middleware injecting activeWorkspaceId runs on the route.
  4. Decode JWT to confirm the workspace claim.

Example fix

// before: token without workspace claim
// after: select workspace, then fetch
await api.post('/workspaces/select', { workspaceId })
await api.get(`/api/v1/chatflows/${id}`)
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 fetching the chatflow
}

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 GET with a token/session lacking activeWorkspaceId. Same root cause as 746 but on the read path: user is in an org but no workspace is selected/assigned.

Common situations: Workspace membership missing; client skipped workspace selection after login; stale token pre-dating workspace assignment; auth middleware that resolves workspace did not run.

Related errors


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