Mintplex-Labs/anything-llm · error

modelId is required

Error message

modelId is required

What it means

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.

Source

Thrown at server/endpoints/utils/lemonadeUtilsEndpoints.js:118

      } catch (e) {
        console.error(e);
        response.write(
          `data: ${JSON.stringify({ type: "error", message: e.message })}\n\n`
        );
      } finally {
        response.end();
      }
    }
  );

  app.post(
    "/utils/lemonade/delete-model",
    [validatedRequest, flexUserRoleValid([ROLES.admin])],
    async (request, response) => {
      try {
        const { modelId, basePath = "" } = reqBody(request);
        if (!modelId) {
          return response.status(400).json({
            success: false,
            error: "modelId is required",
          });
        }

        const lemonadeUrl = new URL(
          parseLemonadeServerEndpoint(
            basePath ?? process.env.LEMONADE_LLM_BASE_PATH,
            "base"
          )
        );
        lemonadeUrl.pathname += "api/v1/delete";

        const lemonadeResponse = await fetch(lemonadeUrl.toString(), {
          method: "POST",
          headers: {
            ...(!!process.env.LEMONADE_LLM_API_KEY
              ? { Authorization: `Bearer ${process.env.LEMONADE_LLM_API_KEY}` }

View on GitHub (pinned to 3aec848f28)

Solutions

  1. POST {"modelId": "<model id as known to Lemonade>"} with Content-Type: application/json.
  2. If unsure of the id, list installed models from the Lemonade server first and copy the exact identifier.
  3. Confirm the caller has the admin role; role failure surfaces differently but often precedes this mistake in debugging.
Defensive patterns

Strategy: validation

Validate before calling

function deleteModel(modelId, basePath = "") {
  if (!modelId || typeof modelId !== "string") throw new Error("modelId is required");
  return fetch("/api/utils/lemonade/delete-model", {
    method: "POST", headers: { "Content-Type": "application/json" },
    body: JSON.stringify({ modelId, basePath }),
  });
}

Type guard

const isNonEmptyString = (v) => typeof v === "string" && v.trim().length > 0;

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: Missing required parameter errors: what 'X is required' and 'the required X param is missing' mean, and how to fix them — this error's family across 27 libraries.

Related errors


AI-assisted analysis of Mintplex-Labs/anything-llm@3aec848f28 (2026-08-18). Data as JSON: /api/errors/698e63a61d5a5517. Report an issue: GitHub.