{"record":{"id":"c5cf31d022991d3a","repo":"FlowiseAI/Flowise","slug":"error-assistantscontroller-updateassistant-work","errorCode":null,"errorMessage":"Error: assistantsController.updateAssistant - workspace ${workspaceId} not found!","messagePattern":"Error: assistantsController\\.updateAssistant - workspace (.+?) not found!","errorType":"exception","errorClass":"InternalFlowiseError","httpStatus":404,"severity":"error","filePath":"packages/server/src/controllers/assistants/index.ts","lineNumber":123,"sourceCode":"}\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            )\n        }\n        if (!req.body) {\n            throw new InternalFlowiseError(\n                StatusCodes.PRECONDITION_FAILED,\n                `Error: assistantsController.updateAssistant - body not provided!`\n            )\n        }\n        const workspaceId = req.user?.activeWorkspaceId\n        if (!workspaceId) {\n            throw new InternalFlowiseError(\n                StatusCodes.NOT_FOUND,\n                `Error: assistantsController.updateAssistant - workspace ${workspaceId} not found!`\n            )\n        }\n        const apiResponse = await assistantsService.updateAssistant(req.params.id, req.body, workspaceId)\n        return res.json(apiResponse)\n    } catch (error) {\n        next(error)\n    }\n}\n\nconst getChatModels = async (req: Request, res: Response, next: NextFunction) => {\n    try {\n        const apiResponse = await assistantsService.getChatModels()\n        return res.json(apiResponse)\n    } catch (error) {\n        next(error)\n    }","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/server/src/controllers/assistants/index.ts#L105-L141","documentation":"Thrown by updateAssistant with HTTP 404 after the id and body guards pass, when req.user?.activeWorkspaceId is falsy. The service updateAssistant(id, body, workspaceId) requires a workspace to scope the update.","triggerScenarios":"Authenticated PUT /api/v1/assistants/<id> with a valid body, from a session with no activeWorkspaceId.","commonSituations":"Editing an assistant after the session lost its workspace context; user with no workspace membership.","solutions":["Select/switch into a workspace, then retry the PUT.","Verify auth middleware populates activeWorkspaceId and 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  await updateAssistant(id, payload)\n} catch (err) {\n  if (err?.statusCode === 404 && /workspace .* not found/i.test(err.message)) {\n    await selectWorkspace()\n    return updateAssistant(id, payload)\n  }\n  throw err\n}","preventionTips":["Ensure a workspace is selected before saving edits.","Handle workspace 404s with select-then-retry.","Verify workspace membership for the user."],"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-12T18:17:37.767Z"}