Mintplex-Labs/anything-llm · error · Error

Failed to update default system prompt: ${error.message}

Error message

Failed to update default system prompt: ${error.message}

What it means

The DefaultSystemPrompt admin page submits the trimmed prompt via System.updateDefaultSystemPrompt(newSystemPrompt) and throws inside the .then when the API answers success=false, using the server-provided message. The catch shows 'Failed to update default system prompt' — any server-side rejection of the update lands here.

Source

Thrown at frontend/src/pages/Admin/DefaultSystemPrompt/index.jsx:78

    setSystemPromptForm((prev) => ({
      ...prev,
      value,
      isDirty,
      isSubmitting: false,
    }));
  };

  const handleSubmit = async (e) => {
    e.preventDefault();
    setSystemPromptForm((prev) => ({
      ...prev,
      isSubmitting: true,
    }));
    const newSystemPrompt = systemPromptForm.value.trim();
    await System.updateDefaultSystemPrompt(newSystemPrompt)
      .then(({ success, message }) => {
        if (!success) throw new Error(message);

        // If the user has set the default system prompt to the sane default, reset the value to the sane default.
        if (
          !newSystemPrompt ||
          newSystemPrompt.trim() === saneDefaultSystemPrompt
        ) {
          return setSystemPromptForm((prev) => ({
            ...prev,
            value: saneDefaultSystemPrompt,
          }));
        }

        showToast("Default system prompt updated successfully.", "success");
        setSystemPromptForm((prev) => ({
          ...prev,
          default: newSystemPrompt,
          isDirty: false,
          isSubmitting: false,

View on GitHub (pinned to 3aec848f28)

Solutions

  1. Confirm you are logged in as an admin or the instance owner.
  2. Read the exact message from the API response in the Network tab — it distinguishes permission vs storage failures.
  3. Re-login and resubmit if the token had expired.
  4. Check backend logs for the underlying storage error if the message is generic.
Defensive patterns

Strategy: validation

Validate before calling

// Guard the submit before calling the API
const value = systemPromptForm.value.trim();
if (typeof value !== 'string') return; // nothing to submit
if (!window.localStorage.getItem('auth_token')) {
  showToast('Session expired — please log in again.', 'error');
  return;
}

Try / catch

await System.updateDefaultSystemPrompt(value)
  .then(({ success, message }) => {
    if (!success) throw new Error(message);
  })
  .catch((error) => {
    showToast(`Failed to update default system prompt: ${error.message}`, 'error');
  })
  .finally(() => setSystemPromptForm((prev) => ({ ...prev, isSubmitting: false })));

Prevention

When it happens

Trigger: Submitting the form while the admin session expired (401/403), hitting the update endpoint as a non-admin in multi-user mode, or a backend/storage failure while persisting the setting.

Common situations: Non-admin user reaches the admin settings page; token expired before submit; backend throws while writing the system prompt setting.

Related errors


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