{"record":{"id":"caab800e23baf191","repo":"FlowiseAI/Flowise","slug":"error-assistantscontroller-deleteassistant-work","errorCode":null,"errorMessage":"Error: assistantsController.deleteAssistant - workspace ${workspaceId} not found!","messagePattern":"Error: assistantsController\\.deleteAssistant - workspace (.+?) not found!","errorType":"validation","errorClass":"InternalFlowiseError","httpStatus":404,"severity":"error","filePath":"packages/server/src/controllers/assistants/index.ts","lineNumber":56,"sourceCode":"        const apiResponse = await assistantsService.createAssistant(body, orgId, workspaceId)\n\n        return res.json(apiResponse)\n    } catch (error) {\n        next(error)\n    }\n}\n\nconst deleteAssistant = 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.deleteAssistant - 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.deleteAssistant - workspace ${workspaceId} not found!`\n            )\n        }\n        const apiResponse = await assistantsService.deleteAssistant(req.params.id, req.query.isDeleteBoth, workspaceId)\n        return res.json(apiResponse)\n    } catch (error) {\n        next(error)\n    }\n}\n\nconst getAllAssistants = async (req: Request, res: Response, next: NextFunction) => {\n    try {\n        const type = req.query.type as AssistantType\n        const workspaceId = req.user?.activeWorkspaceId\n        if (!workspaceId) {\n            throw new InternalFlowiseError(\n                StatusCodes.NOT_FOUND,","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/server/src/controllers/assistants/index.ts#L38-L74","documentation":"Thrown by deleteAssistant with HTTP 404 after the id guard passes, when req.user?.activeWorkspaceId is falsy. The service call deleteAssistant(id, isDeleteBoth, workspaceId) needs a workspace to scope the delete, so a missing workspace blocks it.","triggerScenarios":"Authenticated DELETE /api/v1/assistants/<id> from a session with no activeWorkspaceId.","commonSituations":"User authenticated but workspace not selected/membership missing; session/JWT missing the workspace claim.","solutions":["Select/switch into a workspace so activeWorkspaceId is in the session, then retry.","Verify auth middleware populates activeWorkspaceId and that the user has a 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 deleteAssistant(id)\n} catch (err) {\n  if (err?.statusCode === 404 && /workspace .* not found/i.test(err.message)) {\n    await selectWorkspace()\n    return deleteAssistant(id)\n  }\n  throw err\n}","preventionTips":["Ensure a workspace is selected before issuing scoped deletes.","Handle workspace 404s with select-then-retry.","Verify the user still has workspace membership."],"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"}