Mintplex-Labs/anything-llm · error

Failed to update default system prompt.

Error message

Failed to update default system prompt.

What it means

Thrown by POST /system/default-system-prompt (admin-only) when SystemSettings.updateSettings({ default_system_prompt }) reports success:false. The settings pipeline validates the field (non-empty string required — non-strings/empty become null), filters to supported fields, and can fail on database write errors; the thrown message is error.message or the literal 'Failed to update default system prompt.' when no message exists. Returned to the client as HTTP 500.

Solutions

  1. Send a non-empty string body { defaultSystemPrompt: 'You are...' } and confirm you are POSTing to /system/default-system-prompt as an admin
  2. Check the server console — the handler logs 'Error updating default system prompt:' with the underlying error.message which names the real cause (DB write, validation)
  3. Fix storage/DB access if logs show write failures (permissions on the anythingllm storage dir, reachable DB, not-locked SQLite)
  4. If you actually want to clear the prompt, check for a dedicated delete/reset route or send the documented sane default text instead of an empty string

Example fix

// before
await api.post('/system/default-system-prompt', { defaultSystemPrompt: '' });
// after
await api.post('/system/default-system-prompt', { defaultSystemPrompt: 'You are a helpful assistant.' });
Defensive patterns

Strategy: validation

Validate before calling

function isValidSystemPrompt(p) { return typeof p === 'string' && p.trim().length > 0; }
if (!isValidSystemPrompt(payload.defaultSystemPrompt)) throw new Error('defaultSystemPrompt must be a non-empty string');

Type guard

function isNonEmptyPrompt(p: unknown): p is string { return typeof p === 'string' && p.trim().length > 0; }

Try / catch

try { await api.post('/system/default-system-prompt', { defaultSystemPrompt }); } catch (e) { if (/Failed to update default system prompt/.test(e.message)) { /* inspect server console 'Error updating default system prompt:' for the DB/validation root cause */ } else throw e; }

Prevention

When it happens

Trigger: POSTing a defaultSystemPrompt that is not a non-empty string (null, empty string) so the field validator nulls it and the update fails; sending the field when the running server version/DB schema doesn't support it; transient or persistent DB errors during the settings write (locked SQLite file, failed Postgres connection).

Common situations: Automation scripts PUT/POSTing the whole settings object including an empty prompt; instances where the storage folder permissions broke (docker volumes); older snapshots restored into a newer schema.

Related errors


AI-assisted analysis of Mintplex-Labs/anything-llm@20f6d3546c (2026-08-18). Data as JSON: /api/errors/687c3e2707712e3e. Report an issue: GitHub.

Appendix: source

Thrown at server/endpoints/system.js:907

        console.error("Error fetching default system prompt:", error);
        response
          .status(500)
          .json({ success: false, message: "Internal server error" });
      }
    }
  );

  app.post(
    "/system/default-system-prompt",
    [validatedRequest, flexUserRoleValid([ROLES.admin])],
    async (request, response) => {
      try {
        const { defaultSystemPrompt } = reqBody(request);
        const { success, error } = await SystemSettings.updateSettings({
          default_system_prompt: defaultSystemPrompt,
        });
        if (!success)
          throw new Error(
            error.message || "Failed to update default system prompt."
          );
        response.status(200).json({
          success: true,
          message: "Default system prompt updated successfully.",
        });
      } catch (error) {
        console.error("Error updating default system prompt:", error);
        response.status(500).json({
          success: false,
          message: error.message || "Internal server error",
        });
      }
    }
  );

  app.delete(
    "/system/remove-pfp",

View on GitHub (pinned to 20f6d3546c)