FlowiseAI/Flowise · error · InternalFlowiseError

Error: credentialsController.getCredentialById - workspace $

Error message

Error: credentialsController.getCredentialById - workspace ${workspaceId} not found!

What it means

Thrown by getCredentialById when req.user.activeWorkspaceId is falsy. Same root cause as errors 780/781: the user is authenticated but their session/JWT does not carry an active workspace. Returns HTTP 404 NOT_FOUND even though the real defect is in the auth claim, not a missing resource.

Source

Thrown at packages/server/src/controllers/credentials/index.ts:71

        }
        const apiResponse = await credentialsService.getAllCredentials(req.query.credentialName, workspaceId)
        return res.json(apiResponse)
    } catch (error) {
        next(error)
    }
}

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

const revealCredentialById = async (req: Request, res: Response, next: NextFunction) => {
    try {
        if (typeof req.params === 'undefined' || !req.params.id) {
            throw new InternalFlowiseError(
                StatusCodes.PRECONDITION_FAILED,
                `Error: credentialsController.revealCredentialById - id not provided!`
            )

View on GitHub (pinned to abe4a8601a)

Solutions

  1. Re-login so a fresh JWT includes activeWorkspaceId.
  2. Confirm the user still has membership in the target workspace; re-add if revoked.
  3. Switch active workspace via the workspace-switch endpoint before fetching the credential.
  4. In tests, populate req.user.activeWorkspaceId in your auth stub.

Example fix

// test stub fix
const authenticatedReq = {
  params: { id: 'abc-123' },
  user: { activeWorkspaceId: 'ws-uuid' } // add this
}
Defensive patterns

Strategy: validation

Validate before calling

function assertActiveWorkspace(user: unknown): string {
  const ws = (user as any)?.activeWorkspaceId
  if (typeof ws !== 'string' || ws.length === 0) {
    throw new Error('no activeWorkspaceId — re-login required')
  }
  return ws
}

if (isNonEmptyString(params.id)) {
  await api.getCredentialById(params.id, assertActiveWorkspace(currentUser))
}

Type guard

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

Try / catch

try {
  await api.getCredentialById(id)
} catch (e) {
  if (e.status === 404 && /workspace .* not found/.test(e.message)) {
    await auth.relogin()
  } else throw e
}

Prevention

When it happens

Trigger: GET /api/v1/credentials/:id with a valid id but a JWT whose payload omits activeWorkspaceId. Happens after org-level login that never bound a workspace, or when the user's workspace membership was revoked but the token is still valid.

Common situations: Token minted in OSS mode reused against enterprise endpoints. Stale cookie after admin reorganized workspaces. Test harness authenticating with a service token that has no workspace claim.

Related errors


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