{"record":{"id":"161dab7362489f9b","repo":"FlowiseAI/Flowise","slug":"error-assistantscontroller-updateassistant-id-n","errorCode":null,"errorMessage":"Error: assistantsController.updateAssistant - id not provided!","messagePattern":"Error: assistantsController\\.updateAssistant - id not provided!","errorType":"exception","errorClass":"InternalFlowiseError","httpStatus":412,"severity":"warning","filePath":"packages/server/src/controllers/assistants/index.ts","lineNumber":110,"sourceCode":"        }\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            )\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)","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/server/src/controllers/assistants/index.ts#L92-L128","documentation":"Thrown by updateAssistant with HTTP 412 when req.params is undefined or req.params.id is falsy. Mounted via routes/assistants/index.ts:15 as PUT ['/', '/:id'], so PUT /api/v1/assistants/ (root) reaches updateAssistant with no id. This is the first of three sequential guards in updateAssistant (id, then body, then workspace).","triggerScenarios":"PUT /api/v1/assistants/ (no id segment) — e.g. a save action with no resource id, or a client PUT to the collection root.","commonSituations":"Create-vs-update ambiguity in the client (PUT to root intending create); id variable empty when the edit form had no loaded resource.","solutions":["Call PUT /api/v1/assistants/<id> with the resource id to update.","Guard id is a non-empty string before issuing the PUT."],"exampleFix":"// before\nawait fetch(`${BASE}/api/v1/assistants/`, { method: 'PUT', headers, body: JSON.stringify(payload) })\n\n// after\nif (!assistantId) throw new Error('assistant id required')\nawait fetch(`${BASE}/api/v1/assistants/${encodeURIComponent(assistantId)}`, { method: 'PUT', headers, body: JSON.stringify(payload) })","handlingStrategy":"validation","validationCode":"function assertId(id: unknown): string {\n  if (typeof id !== 'string' || id.trim() === '') {\n    throw new Error('assistant id is required to update')\n  }\n  return id\n}\nconst id = assertId(selectedId)\nawait fetch(`${BASE}/api/v1/assistants/${encodeURIComponent(id)}`, { method: 'PUT', headers, body: JSON.stringify(payload) })","typeGuard":"const isNonEmptyString = (v: unknown): v is string =>\n  typeof v === 'string' && v.trim().length > 0","tryCatchPattern":null,"preventionTips":["Never PUT to the collection root for updates; include the id.","Distinguish create (POST /) from update (PUT /<id>) in the client.","Disable save until an editable resource is loaded."],"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"}