{"record":{"id":"1530af53bc3a0736","repo":"Mintplex-Labs/anything-llm","slug":"this-feature-has-been-disabled-by-the-administrato","errorCode":null,"errorMessage":"This feature has been disabled by the administrator.","messagePattern":"This feature has been disabled by the administrator\\.","errorType":"http","errorClass":null,"httpStatus":422,"severity":"warning","filePath":"server/utils/middleware/chatHistoryViewable.js","lineNumber":11,"sourceCode":"/**\n * A simple middleware that validates that the chat history is viewable.\n * via the `DISABLE_VIEW_CHAT_HISTORY` environment variable being set AT ALL.\n * @param {Request} request - The request object.\n * @param {Response} response - The response object.\n * @param {NextFunction} next - The next function.\n */\nfunction chatHistoryViewable(_request, response, next) {\n  if (\"DISABLE_VIEW_CHAT_HISTORY\" in process.env)\n    return response\n      .status(422)\n      .send(\"This feature has been disabled by the administrator.\");\n  next();\n}\n\nmodule.exports = {\n  chatHistoryViewable,\n};\n","sourceCodeStart":1,"sourceCodeEnd":19,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/3aec848f2885144aa8f1e53b9731a04310d5d558/server/utils/middleware/chatHistoryViewable.js#L1-L19","documentation":"Gate middleware for chat-history endpoints. It checks presence, not value: if the DISABLE_VIEW_CHAT_HISTORY environment variable exists AT ALL ('in process.env'), every request to a chat-history route gets HTTP 422 with 'This feature has been disabled by the administrator.'. Setting it to 'false' or '0' does NOT re-enable the feature — only removing the variable does.","triggerScenarios":"Any GET of workspace chat history or embed chat history while DISABLE_VIEW_CHAT_HISTORY is defined in the environment, including DISABLE_VIEW_CHAT_HISTORY=false, =0, or an empty value.","commonSituations":"Admin sets DISABLE_VIEW_CHAT_HISTORY=false expecting to allow history; CI/compose files define the key with an empty value; a container image bakes the variable in so it survives .env edits; Kubernetes ConfigMap has the key set to 'false'.","solutions":["Delete or comment out the DISABLE_VIEW_CHAT_HISTORY line in .env — do not set it to false","Restart the server / recreate the container so the environment is re-read","Verify inside the container: printenv | grep DISABLE_VIEW_CHAT_HISTORY must return nothing"],"exampleFix":"# before (.env)\nDISABLE_VIEW_CHAT_HISTORY=false   # still blocks: presence check, not value\n\n# after (.env)\n# DISABLE_VIEW_CHAT_HISTORY=       # line removed -> feature re-enabled","handlingStrategy":"fallback","validationCode":"// server-side, before shipping a build that relies on chat history\nif (\"DISABLE_VIEW_CHAT_HISTORY\" in process.env) {\n  console.warn('Chat history UI will 422: DISABLE_VIEW_CHAT_HISTORY is set (to ANY value)');\n}","typeGuard":null,"tryCatchPattern":"const res = await fetch('/api/workspace/:slug/chats');\nif (res.status === 422) {\n  disableHistoryUI(); // feature intentionally off — degrade, don't retry\n}","preventionTips":["Never set a presence-checked flag to false — remove the line instead","Document which env flags are presence-based vs value-based","After env edits, recreate the container and verify with printenv"],"tags":["environment-variable","feature-flag","anythingllm","http-422"],"backgroundTag":"feature-flag-disabled","analyzedSha":"3aec848f2885144aa8f1e53b9731a04310d5d558","analyzedAt":"2026-08-18T10:02:21.017Z","contentChangedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}