{"record":{"id":"0e436138329b9531","repo":"FlowiseAI/Flowise","slug":"error-assistantscontroller-getassistantbyid-wor","errorCode":null,"errorMessage":"Error: assistantsController.getAssistantById - workspace ${workspaceId} not found!","messagePattern":"Error: assistantsController\\.getAssistantById - workspace (.+?) not found!","errorType":"exception","errorClass":"InternalFlowiseError","httpStatus":404,"severity":"error","filePath":"packages/server/src/controllers/assistants/index.ts","lineNumber":95,"sourceCode":"        }\n        const apiResponse = await assistantsService.getAllAssistants(workspaceId, type)\n        return res.json(apiResponse)\n    } catch (error) {\n        next(error)\n    }\n}\n\nconst getAssistantById = async (req: Request, res: Response, next: NextFunction) => {\n    try {\n        if (typeof req.params === 'undefined' || !req.params.id) {\n            throw new InternalFlowiseError(\n                StatusCodes.PRECONDITION_FAILED,\n                `Error: assistantsController.getAssistantById - id not provided!`\n            )\n        }\n        const workspaceId = req.user?.activeWorkspaceId\n        if (!workspaceId) {\n            throw new InternalFlowiseError(\n                StatusCodes.NOT_FOUND,\n                `Error: assistantsController.getAssistantById - workspace ${workspaceId} not found!`\n            )\n        }\n        const apiResponse = await assistantsService.getAssistantById(req.params.id, workspaceId)\n        return res.json(apiResponse)\n    } catch (error) {\n        next(error)\n    }\n}\n\nconst updateAssistant = async (req: Request, res: Response, next: NextFunction) => {\n    try {\n        if (typeof req.params === 'undefined' || !req.params.id) {\n            throw new InternalFlowiseError(\n                StatusCodes.PRECONDITION_FAILED,\n                `Error: assistantsController.updateAssistant - id not provided!`\n            )","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/server/src/controllers/assistants/index.ts#L77-L113","documentation":"Thrown by getAssistantById with HTTP 404 after the id guard passes, when req.user?.activeWorkspaceId is falsy. The lookup getAssistantById(id, workspaceId) is workspace-scoped, so a missing workspace blocks it.","triggerScenarios":"Authenticated GET /api/v1/assistants/<id> from a session with no activeWorkspaceId.","commonSituations":"Direct-link/deep-link to an assistant before workspace selection; session expired/reset; no workspace membership.","solutions":["Select/switch into a workspace, then retry.","Verify auth middleware populates activeWorkspaceId and the user's workspace membership."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"const hasActiveWorkspace = (u: unknown): u is { activeWorkspaceId: string } =>\n  !!u && typeof u === 'object' &&\n  typeof (u as any).activeWorkspaceId === 'string' &&\n  (u as any).activeWorkspaceId.length > 0","tryCatchPattern":"try {\n  return await getAssistantById(id)\n} catch (err) {\n  if (err?.statusCode === 404 && /workspace .* not found/i.test(err.message)) {\n    await selectWorkspace()\n    return getAssistantById(id)\n  }\n  throw err\n}","preventionTips":["For deep links, ensure workspace selection completes before fetching the resource.","Handle workspace 404s with select-then-retry rather than treating them as not-found resources.","Require activeWorkspaceId in the session before deep-link fetches."],"tags":["authentication","session","workspace","not-found","express","flowise","assistants"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}