{"record":{"id":"4fcee36e22a4d865","repo":"Mintplex-Labs/anything-llm","slug":"data-message-error-creating-slash-command-pres","errorCode":null,"errorMessage":"data.message || \"Error creating slash command preset.\"","messagePattern":"data\\.message \\|\\| \"Error creating slash command preset\\.\"","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"frontend/src/models/system.js","lineNumber":728,"sourceCode":"        return res.json();\n      })\n      .then((res) => res.presets)\n      .catch((e) => {\n        console.error(e);\n        return [];\n      });\n  },\n\n  createSlashCommandPreset: async function (presetData) {\n    return await fetch(`${API_BASE}/system/slash-command-presets`, {\n      method: \"POST\",\n      headers: baseHeaders(),\n      body: JSON.stringify(presetData),\n    })\n      .then(async (res) => {\n        const data = await res.json();\n        if (!res.ok)\n          throw new Error(\n            data.message || \"Error creating slash command preset.\"\n          );\n        return data;\n      })\n      .then((res) => ({ preset: res.preset, error: null }))\n      .catch((e) => {\n        console.error(e);\n        return { preset: null, error: e.message };\n      });\n  },\n\n  updateSlashCommandPreset: async function (presetId, presetData) {\n    return await fetch(`${API_BASE}/system/slash-command-presets/${presetId}`, {\n      method: \"POST\",\n      headers: baseHeaders(),\n      body: JSON.stringify(presetData),\n    })\n      .then(async (res) => {","sourceCodeStart":710,"sourceCodeEnd":746,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/3aec848f2885144aa8f1e53b9731a04310d5d558/frontend/src/models/system.js#L710-L746","documentation":"Thrown by createSlashCommandPreset in the AnythingLLM frontend when POST /api/system/slash-command-presets responds non-2xx. It prefers the server's data.message (validation detail) over the generic fallback. Presets are per-user command shortcuts, and the server validates the submitted shape before inserting.","triggerScenarios":"Posting presetData missing required fields (empty command or name), with wrong-typed values, or with a command that already exists for the user (duplicate rejection); any database error during insert also lands here.","commonSituations":"Creating a preset whose command collides with an existing one; frontend form allowing empty submissions after a state reset; DB unavailable on self-hosted instances.","solutions":["Ensure presetData carries every required field (command, name, etc.) with expected types before submitting.","Pick a command string that does not duplicate an existing preset for the same user.","Read the returned `error` — when the server supplies data.message it names the failing field.","Check server logs if the failure is a database error rather than validation."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// run before System.createSlashCommandPreset\nfunction validPreset(p) {\n  return (\n    typeof p?.command === 'string' && p.command.trim().length > 0 &&\n    typeof p?.name === 'string' && p.name.trim().length > 0\n  );\n}\nif (!validPreset(presetData)) throw new Error('Command and name are required');","typeGuard":"/** @param {any} r @returns {r is {preset: object, error: null}} */\nfunction isPresetCreated(r) {\n  return typeof r === 'object' && r !== null && r.preset != null && r.error === null;\n}","tryCatchPattern":"const { preset, error } = await System.createSlashCommandPreset(presetData);\nif (error) {\n  showPresetError(error); // server data.message names the failing field\n  return;\n}","preventionTips":["Validate required preset fields client-side before posting.","Keep commands unique per user to avoid duplicate rejection.","Render the server's data.message — it is field-specific and more useful than the fallback."],"tags":["anythingllm","slash-command-presets","validation","http"],"backgroundTag":"api-validation-failed","analyzedSha":"3aec848f2885144aa8f1e53b9731a04310d5d558","analyzedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}