{"record":{"id":"ba26e5419453451c","repo":"FlowiseAI/Flowise","slug":"error-assistantscontroller-getassistantbyid-id","errorCode":null,"errorMessage":"Error: assistantsController.getAssistantById - id not provided!","messagePattern":"Error: assistantsController\\.getAssistantById - id not provided!","errorType":"exception","errorClass":"InternalFlowiseError","httpStatus":412,"severity":"warning","filePath":"packages/server/src/controllers/assistants/index.ts","lineNumber":88,"sourceCode":"        const type = req.query.type as AssistantType\n        const workspaceId = req.user?.activeWorkspaceId\n        if (!workspaceId) {\n            throw new InternalFlowiseError(\n                StatusCodes.NOT_FOUND,\n                `Error: assistantsController.getAllAssistants - workspace ${workspaceId} not found!`\n            )\n        }\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","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/server/src/controllers/assistants/index.ts#L70-L106","documentation":"Thrown by getAssistantById with HTTP 412 when req.params is undefined or req.params.id is falsy. Mounted via routes/assistants/index.ts:12 as GET ['/', '/:id'], so GET /api/v1/assistants/ (root) reaches getAssistantById with no id and throws.","triggerScenarios":"GET /api/v1/assistants/ (no id segment). Client fetching by an empty id variable so the URL collapses to the root. (Note: GET /api/v1/assistants with no trailing slash is handled by getAllAssistants, a different handler.)","commonSituations":"Detail-view fetch fired before an assistant id is known; routing bug that drops the id; test calling the collection root expecting a single resource.","solutions":["Call GET /api/v1/assistants/<id> with a concrete id.","Guard id client-side before fetching."],"exampleFix":"// before\nawait fetch(`${BASE}/api/v1/assistants/`, { headers })\n\n// after\nif (!assistantId) throw new Error('assistant id required')\nawait fetch(`${BASE}/api/v1/assistants/${encodeURIComponent(assistantId)}`, { headers })","handlingStrategy":"validation","validationCode":"function assertId(id: unknown): string {\n  if (typeof id !== 'string' || id.trim() === '') {\n    throw new Error('assistant id is required')\n  }\n  return id\n}\nconst id = assertId(selectedId)\nawait fetch(`${BASE}/api/v1/assistants/${encodeURIComponent(id)}`, { headers })","typeGuard":"const isNonEmptyString = (v: unknown): v is string =>\n  typeof v === 'string' && v.trim().length > 0","tryCatchPattern":null,"preventionTips":["Fetch detail views by concrete id only; never the collection root.","Distinguish GET / (list) from GET /<id> (detail) in client routing.","Guard empty ids before building the URL."],"tags":["validation","express","path-param","precondition-failed","flowise","assistants"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}