{"record":{"id":"c6a05915c22d9f83","repo":"Mintplex-Labs/anything-llm","slug":"failed-to-update-default-system-prompt-error-me","errorCode":null,"errorMessage":"Failed to update default system prompt: ${error.message}","messagePattern":"Failed to update default system prompt: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"frontend/src/pages/Admin/DefaultSystemPrompt/index.jsx","lineNumber":78,"sourceCode":"\n    setSystemPromptForm((prev) => ({\n      ...prev,\n      value,\n      isDirty,\n      isSubmitting: false,\n    }));\n  };\n\n  const handleSubmit = async (e) => {\n    e.preventDefault();\n    setSystemPromptForm((prev) => ({\n      ...prev,\n      isSubmitting: true,\n    }));\n    const newSystemPrompt = systemPromptForm.value.trim();\n    await System.updateDefaultSystemPrompt(newSystemPrompt)\n      .then(({ success, message }) => {\n        if (!success) throw new Error(message);\n\n        // If the user has set the default system prompt to the sane default, reset the value to the sane default.\n        if (\n          !newSystemPrompt ||\n          newSystemPrompt.trim() === saneDefaultSystemPrompt\n        ) {\n          return setSystemPromptForm((prev) => ({\n            ...prev,\n            value: saneDefaultSystemPrompt,\n          }));\n        }\n\n        showToast(\"Default system prompt updated successfully.\", \"success\");\n        setSystemPromptForm((prev) => ({\n          ...prev,\n          default: newSystemPrompt,\n          isDirty: false,\n          isSubmitting: false,","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/3aec848f2885144aa8f1e53b9731a04310d5d558/frontend/src/pages/Admin/DefaultSystemPrompt/index.jsx#L60-L96","documentation":"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.","triggerScenarios":"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.","commonSituations":"Non-admin user reaches the admin settings page; token expired before submit; backend throws while writing the system prompt setting.","solutions":["Confirm you are logged in as an admin or the instance owner.","Read the exact message from the API response in the Network tab — it distinguishes permission vs storage failures.","Re-login and resubmit if the token had expired.","Check backend logs for the underlying storage error if the message is generic."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Guard the submit before calling the API\nconst value = systemPromptForm.value.trim();\nif (typeof value !== 'string') return; // nothing to submit\nif (!window.localStorage.getItem('auth_token')) {\n  showToast('Session expired — please log in again.', 'error');\n  return;\n}","typeGuard":null,"tryCatchPattern":"await System.updateDefaultSystemPrompt(value)\n  .then(({ success, message }) => {\n    if (!success) throw new Error(message);\n  })\n  .catch((error) => {\n    showToast(`Failed to update default system prompt: ${error.message}`, 'error');\n  })\n  .finally(() => setSystemPromptForm((prev) => ({ ...prev, isSubmitting: false })));","preventionTips":["Keep admin settings routes behind an auth check so expired sessions redirect to login instead of failing on submit.","Always render the server's message — it distinguishes permission failures from storage failures.","Reset isSubmitting in a finally block so a failure never leaves the form stuck."],"tags":["system-prompt","admin-ui","api-error","settings"],"backgroundTag":"api-request-failed","analyzedSha":"3aec848f2885144aa8f1e53b9731a04310d5d558","analyzedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}