Mintplex-Labs/anything-llm · error

An error occurred while deleting the model

Error message

An error occurred while deleting the model

What it means

The failure reply from POST /utils/lemonade/delete-model when deletion on the Lemonade server does not succeed. Two paths produce it: the Lemonade /api/v1/delete HTTP response was non-ok and carried no message field (the literal fallback text is used), or the fetch itself threw (server down, wrong base path) and the catch returns e.message with the same fallback. Note that on the catch path e.message is usually non-empty, so seeing the literal string typically means a non-ok HTTP response.

Source

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

            model_name: String(modelId),
          }),
        });

        const data = await lemonadeResponse.json();
        if (!lemonadeResponse.ok || data.status === "error") {
          return response.status(lemonadeResponse.status || 500).json({
            success: false,
            error: data.message || "An error occurred while deleting the model",
          });
        }

        return response.status(200).json({
          success: true,
          message: data.message || `Deleted model: ${modelId}`,
        });
      } catch (e) {
        console.error(e);
        return response.status(500).json({
          success: false,
          error: e.message || "An error occurred while deleting the model",
        });
      }
    }
  );
}

module.exports = {
  lemonadeUtilsEndpoints,
};

View on GitHub (pinned to 3aec848f28)

Solutions

  1. Verify the Lemonade server is up and reachable at the resolved endpoint (default base path or the basePath you passed) - e.g. curl its root/models endpoint.
  2. Confirm the modelId exists on that server before deleting; deleting an unknown id yields a non-ok response.
  3. Correct basePath/LEMONADE_LLM_BASE_PATH (scheme + host + port, no duplicated path segments) and retry.
  4. Check the server console - the catch branch console.errors the raw exception for fetch-level failures.
Defensive patterns

Strategy: validation

Validate before calling

// Confirm the Lemonade server is reachable before deleting
async function lemonadeOnline(basePath) {
  const base = basePath || process.env.LEMONADE_LLM_BASE_PATH;
  try {
    const res = await fetch(new URL("models", base));
    return res.ok;
  } catch { return false; }
}
if (!(await lemonadeOnline(basePath))) throw new Error("Lemonade server unreachable - start it or fix basePath");

Try / catch

try {
  const res = await fetch("/api/utils/lemonade/delete-model", { method: "POST", headers, body: JSON.stringify({ modelId, basePath }) });
  const data = await res.json();
  if (!res.ok) {
    if (/Failed to fetch|ECONN|invalid URL/i.test(data.error)) fixBasePath();
    else refreshModelList(); // model may already be gone
  }
} catch (e) { console.error("delete-model request failed:", e.message); }

Prevention

When it happens

Trigger: Lemonade server not running at the resolved base URL; basePath or LEMONADE_LLM_BASE_PATH pointing at the wrong host/port; deleting a model id that is not installed (404 without message); Lemonade busy/unloaded so the delete endpoint returns 5xx; URL construction throwing on a malformed basePath.

Common situations: Lemonade started on a non-default port while the client sends the default; inference server crashed mid-session; model already deleted by another tab; basePath passed with a trailing slash or missing scheme producing an invalid URL.

Understand the failure class

Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.

Related errors


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