{"record":{"id":"698e63a61d5a5517","repo":"Mintplex-Labs/anything-llm","slug":"modelid-is-required","errorCode":null,"errorMessage":"modelId is required","messagePattern":"modelId is required","errorType":"http","errorClass":null,"httpStatus":400,"severity":"error","filePath":"server/endpoints/utils/lemonadeUtilsEndpoints.js","lineNumber":118,"sourceCode":"      } catch (e) {\n        console.error(e);\n        response.write(\n          `data: ${JSON.stringify({ type: \"error\", message: e.message })}\\n\\n`\n        );\n      } finally {\n        response.end();\n      }\n    }\n  );\n\n  app.post(\n    \"/utils/lemonade/delete-model\",\n    [validatedRequest, flexUserRoleValid([ROLES.admin])],\n    async (request, response) => {\n      try {\n        const { modelId, basePath = \"\" } = reqBody(request);\n        if (!modelId) {\n          return response.status(400).json({\n            success: false,\n            error: \"modelId is required\",\n          });\n        }\n\n        const lemonadeUrl = new URL(\n          parseLemonadeServerEndpoint(\n            basePath ?? process.env.LEMONADE_LLM_BASE_PATH,\n            \"base\"\n          )\n        );\n        lemonadeUrl.pathname += \"api/v1/delete\";\n\n        const lemonadeResponse = await fetch(lemonadeUrl.toString(), {\n          method: \"POST\",\n          headers: {\n            ...(!!process.env.LEMONADE_LLM_API_KEY\n              ? { Authorization: `Bearer ${process.env.LEMONADE_LLM_API_KEY}` }","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/3aec848f2885144aa8f1e53b9731a04310d5d558/server/endpoints/utils/lemonadeUtilsEndpoints.js#L100-L136","documentation":"The 400 reply from POST /utils/lemonade/delete-model when the request body has no modelId. modelId identifies which model to remove from the Lemonade inference server; it is the only mandatory field (basePath defaults to ''), so reqBody(request) returning a falsy modelId fails fast before any Lemonade URL is constructed.","triggerScenarios":"POST /utils/lemonade/delete-model as an admin/flex user with an empty body, a key mismatch (model_id, id, name), or a JSON body that never parsed due to a missing Content-Type header. Requires ROLES.admin - non-admin callers are rejected earlier by flexUserRoleValid.","commonSituations":"Automated cleanup script iterating a model list and sending an undefined entry; frontend sending the display label under a different key; curl without the JSON header.","solutions":["POST {\"modelId\": \"<model id as known to Lemonade>\"} with Content-Type: application/json.","If unsure of the id, list installed models from the Lemonade server first and copy the exact identifier.","Confirm the caller has the admin role; role failure surfaces differently but often precedes this mistake in debugging."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"function deleteModel(modelId, basePath = \"\") {\n  if (!modelId || typeof modelId !== \"string\") throw new Error(\"modelId is required\");\n  return fetch(\"/api/utils/lemonade/delete-model\", {\n    method: \"POST\", headers: { \"Content-Type\": \"application/json\" },\n    body: JSON.stringify({ modelId, basePath }),\n  });\n}","typeGuard":"const isNonEmptyString = (v) => typeof v === \"string\" && v.trim().length > 0;","tryCatchPattern":null,"preventionTips":["Filter undefined/null out of model lists before looping delete calls.","Use the exact model id known to the Lemonade server, not the display name.","Call as an admin-role user; the endpoint is role-gated."],"tags":["lemonade","model-management","validation","missing-parameter"],"backgroundTag":"missing-required-parameter","analyzedSha":"3aec848f2885144aa8f1e53b9731a04310d5d558","analyzedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-08-23T11:17:13.642Z"}