{"record":{"id":"687c3e2707712e3e","repo":"Mintplex-Labs/anything-llm","slug":"failed-to-update-default-system-prompt","errorCode":null,"errorMessage":"Failed to update default system prompt.","messagePattern":"Failed to update default system prompt\\.","errorType":"exception","errorClass":"Error","httpStatus":500,"severity":"error","filePath":"server/endpoints/system.js","lineNumber":893,"sourceCode":"        console.error(\"Error fetching default system prompt:\", error);\n        response\n          .status(500)\n          .json({ success: false, message: \"Internal server error\" });\n      }\n    }\n  );\n\n  app.post(\n    \"/system/default-system-prompt\",\n    [validatedRequest, flexUserRoleValid([ROLES.admin])],\n    async (request, response) => {\n      try {\n        const { defaultSystemPrompt } = reqBody(request);\n        const { success, error } = await SystemSettings.updateSettings({\n          default_system_prompt: defaultSystemPrompt,\n        });\n        if (!success)\n          throw new Error(\n            error.message || \"Failed to update default system prompt.\"\n          );\n        response.status(200).json({\n          success: true,\n          message: \"Default system prompt updated successfully.\",\n        });\n      } catch (error) {\n        console.error(\"Error updating default system prompt:\", error);\n        response.status(500).json({\n          success: false,\n          message: error.message || \"Internal server error\",\n        });\n      }\n    }\n  );\n\n  app.delete(\n    \"/system/remove-pfp\",","sourceCodeStart":875,"sourceCodeEnd":911,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/endpoints/system.js#L875-L911","documentation":"Thrown by POST /system/default-system-prompt when SystemSettings.updateSettings returns { success: false }. The thrown Error uses error.message when present, falling back to this string only when the failure carried no message. updateSettings is the generic system-settings persistence layer (typically a DB upsert), so the real cause is whatever made that layer report failure.","triggerScenarios":"An admin saves a new default system prompt but the database write fails, a validation inside updateSettings rejects the value, or the settings table/row is locked or missing. The fallback text appears only when the inner error object had no message.","commonSituations":"Database connection dropped mid-request; the prompt text exceeded a column size limit; a migration left the system_settings table in an unexpected state; Prisma threw a constraint violation.","solutions":["Inspect server logs — the console.error in the catch logs the underlying error with its real message.","Confirm the database is reachable and the system_settings table exists (run migrations).","Reduce the prompt length and retry to rule out a size constraint.","If the inner error is transient (lock/timeout), retry the save."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const { success, error } = await SystemSettings.updateSettings({ default_system_prompt: prompt });\n  if (!success) throw new Error(error?.message || 'updateSettings failed');\n} catch (e) {\n  logger.error('default-system-prompt update failed', { cause: e });\n  res.status(500).json({ success: false, message: e.message });\n}","preventionTips":["Log the inner error object to capture the real DB message.","Validate prompt length on the client to avoid DB size constraints.","Ensure migrations are applied so system_settings exists."],"tags":["system-settings","database","admin","system-prompt"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}