FlowiseAI/Flowise · error · InternalFlowiseError
Error: assistantsController.createAssistant - organization $
Error message
Error: assistantsController.createAssistant - organization ${orgId} not found! What it means
Thrown by createAssistant with HTTP 404 (NOT_FOUND) after the body guard passes, when orgId = req.user?.activeOrganizationId is falsy. The interpolated value in the message will be 'undefined' or 'null'. The organization id is attached by the auth/session middleware; its absence means the caller is authenticated but has no active organization context, so the assistant cannot be scoped/created.
Source
Thrown at packages/server/src/controllers/assistants/index.ts:20
import { StatusCodes } from 'http-status-codes'
import { InternalFlowiseError } from '../../errors/internalFlowiseError'
import { AssistantType } from '../../Interface'
import assistantsService from '../../services/assistants'
import { getRunningExpressApp } from '../../utils/getRunningExpressApp'
import { checkUsageLimit } from '../../utils/quotaUsage'
const createAssistant = async (req: Request, res: Response, next: NextFunction) => {
try {
if (!req.body) {
throw new InternalFlowiseError(
StatusCodes.PRECONDITION_FAILED,
`Error: assistantsController.createAssistant - body not provided!`
)
}
const body = req.body
const orgId = req.user?.activeOrganizationId
if (!orgId) {
throw new InternalFlowiseError(
StatusCodes.NOT_FOUND,
`Error: assistantsController.createAssistant - organization ${orgId} not found!`
)
}
const workspaceId = req.user?.activeWorkspaceId
if (!workspaceId) {
throw new InternalFlowiseError(
StatusCodes.NOT_FOUND,
`Error: assistantsController.createAssistant - workspace ${workspaceId} not found!`
)
}
const subscriptionId = req.user?.activeOrganizationSubscriptionId || ''
const existingAssistantCount = await assistantsService.getAssistantsCountByOrganization(body.type, orgId)
const newAssistantCount = 1
await checkUsageLimit('flows', subscriptionId, getRunningExpressApp().usageCacheManager, existingAssistantCount + newAssistantCount)
const apiResponse = await assistantsService.createAssistant(body, orgId, workspaceId)View on GitHub (pinned to abe4a8601a)
Solutions
- Ensure the user belongs to an organization and the session/JWT carries activeOrganizationId before creating an assistant.
- Have the client select/switch into an organization, then retry.
- Verify the auth middleware populates activeOrganizationId on req.user for this deployment.
Defensive patterns
Strategy: try-catch
Type guard
const hasActiveOrg = (u: unknown): u is { activeOrganizationId: string } =>
!!u && typeof u === 'object' &&
typeof (u as any).activeOrganizationId === 'string' &&
(u as any).activeOrganizationId.length > 0 Try / catch
try {
await createAssistant(payload)
} catch (err) {
if (err?.statusCode === 404 && /organization .* not found/i.test(err.message)) {
await selectOrganization() // establish activeOrganizationId
return createAssistant(payload)
}
throw err
} Prevention
- Require an active organization in the session before enabling assistant creation.
- On 404 'organization ... not found', prompt org selection then retry once.
- Ensure provisioning assigns every user to an org.
When it happens
Trigger: POST /api/v1/assistants with a valid JSON body from a session whose JWT has no activeOrganizationId — e.g. a user not belonging to any organization, or an org claim that was never set.
Common situations: User invited but not yet assigned to an organization; SSO/JIT provisioning that created the user without an org; JWT minted without the org claim; running in a non-enterprise/single-user mode where activeOrganizationId is never populated but this enterprise-guarded route is still reached.
Related errors
- Error: assistantsController.createAssistant - workspace ${wo
- Error: assistantsController.deleteAssistant - workspace ${wo
- Error: assistantsController.getAllAssistants - workspace ${w
- Error: assistantsController.getAssistantById - workspace ${w
- Error: assistantsController.updateAssistant - workspace ${wo
AI-assisted analysis of FlowiseAI/Flowise@abe4a8601a (2026-08-12).
Data as JSON: /api/errors/dc85cc5d06c66f1d.
Report an issue: GitHub.