Mintplex-Labs/anything-llm · error · Error

Could not update slash command preset.

Error message

Could not update slash command preset.

What it means

Thrown when POST /system/slash-command-presets/:presetId returns non-2xx during an update. Same body-aware pattern as create (prefers data.message). The .catch returns { preset: null, error }. Note the route uses POST (not PATCH/PUT) for the update.

Source

Thrown at frontend/src/models/system.js:749

        return data;
      })
      .then((res) => ({ preset: res.preset, error: null }))
      .catch((e) => {
        console.error(e);
        return { preset: null, error: e.message };
      });
  },

  updateSlashCommandPreset: async function (presetId, presetData) {
    return await fetch(`${API_BASE}/system/slash-command-presets/${presetId}`, {
      method: "POST",
      headers: baseHeaders(),
      body: JSON.stringify(presetData),
    })
      .then(async (res) => {
        const data = await res.json();
        if (!res.ok)
          throw new Error(
            data.message || "Could not update slash command preset."
          );
        return data;
      })
      .then((res) => ({ preset: res.preset, error: null }))
      .catch((e) => {
        console.error(e);
        return { preset: null, error: e.message };
      });
  },

  deleteSlashCommandPreset: async function (presetId) {
    return await fetch(`${API_BASE}/system/slash-command-presets/${presetId}`, {
      method: "DELETE",
      headers: baseHeaders(),
    })
      .then((res) => {
        if (!res.ok) throw new Error("Could not delete slash command preset.");

View on GitHub (pinned to 526360e320)

Solutions

  1. Confirm presetId still exists (refetch the preset list) before attempting the update.
  2. Surface the returned error string — it is the server's data.message describing the specific failure.
  3. If 403, verify the current user owns the preset or has admin scope.
  4. Ensure the route is hit with POST (not PUT) to match the backend handler.

Example fix

// before
const { preset, error } = await System.updateSlashCommandPreset(presetId, data);

// after — verify existence then update
const existing = presets.find(p => p.id === presetId);
if (!existing) return { preset: null, error: "Preset no longer exists." };
const { preset, error } = await System.updateSlashCommandPreset(presetId, data);
Defensive patterns

Strategy: validation

Validate before calling

// Ensure the preset still exists in the current list before updating.
function presetExists(list, id) {
  return list.some(p => p.id === id);
}

Type guard

function isPresetUpdateResult(x): x is { preset: object; error: null } {
  return x && x.preset !== null && x.error === null;
}

Try / catch

const { preset, error } = await System.updateSlashCommandPreset(presetId, presetData);
if (error) {
  if (/not found|404/i.test(error)) refetchPresets(); // stale id
  showToast(error);
}

Prevention

When it happens

Trigger: presetId does not exist (404), presetId belongs to another user/workspace (403), the new presetData fails validation, or a stale presetId from a deleted row is reused.

Common situations: User edits a preset that was deleted in another tab; presetId is taken from stale component state after a refetch; concurrent delete-then-update race; route param encoding issues with special characters in the id.

Related errors


AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13). Data as JSON: /api/errors/8e421c9d734af6c2. Report an issue: GitHub.