{"record":{"id":"47816a6b9300a5f4","repo":"Mintplex-Labs/anything-llm","slug":"res-statustext-error-setting-watch-status-for","errorCode":null,"errorMessage":"res.statusText || \"Error setting watch status for document.\"","messagePattern":"res\\.statusText \\|\\| \"Error setting watch status for document\\.\"","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"frontend/src/models/experimental/liveSync.js","lineNumber":46,"sourceCode":"        return res.json();\n      })\n      .then((res) => res?.queues || [])\n      .catch((e) => {\n        console.error(e);\n        return [];\n      });\n  },\n\n  // Should be in Workspaces but is here for now while in preview\n  setWatchStatusForDocument: async function (slug, docPath, watchStatus) {\n    return fetch(`${API_BASE}/workspace/${slug}/update-watch-status`, {\n      method: \"POST\",\n      headers: baseHeaders(),\n      body: JSON.stringify({ docPath, watchStatus }),\n    })\n      .then((res) => {\n        if (!res.ok) {\n          throw new Error(\n            res.statusText || \"Error setting watch status for document.\"\n          );\n        }\n        return true;\n      })\n      .catch((e) => {\n        console.error(e);\n        return false;\n      });\n  },\n};\n\nexport default LiveDocumentSync;\n","sourceCodeStart":28,"sourceCodeEnd":60,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/frontend/src/models/experimental/liveSync.js#L28-L60","documentation":"Thrown by LiveDocumentSync.setWatchStatusForDocument when the POST to /workspace/:slug/update-watch-status returns non-OK. The message prefers the HTTP statusText and falls back to 'Error setting watch status for document.' when statusText is empty (common for 500s on some servers). The .catch returns false.","triggerScenarios":"workspace slug does not exist or caller is not a member; docPath not found under that workspace; watchStatus not a value the backend accepts; permission failure; concurrent removal of the document.","commonSituations":"Slug typed with wrong case or trailing slash; docPath moved/deleted between page load and toggle; watchStatus sent as a string when the backend expects a boolean; non-member trying to watch a private workspace doc.","solutions":["Confirm slug and docPath still exist (refresh the workspace tree).","Send watchStatus as a strict boolean matching the backend contract.","Verify the caller is a member of the workspace.","If statusText is empty, fall back to the static message and log the status code."],"exampleFix":"// before\nconst ok = await LiveDocumentSync.setWatchStatusForDocument(slug, docPath, watchStatus);\n\n// after\nconst ok = await LiveDocumentSync.setWatchStatusForDocument(slug, docPath, Boolean(watchStatus));\nif (!ok) showToast('Could not change watch status - document may have moved', 'warning');","handlingStrategy":"validation","validationCode":"function validateWatchArgs(slug, docPath, watchStatus) {\n  if (!slug?.trim()) return 'slug is required';\n  if (!docPath?.trim()) return 'docPath is required';\n  if (typeof watchStatus !== 'boolean') return 'watchStatus must be boolean';\n  return null;\n}","typeGuard":"/** @param {unknown} r */\nfunction isWatchResult(r) { return typeof r === 'boolean'; }","tryCatchPattern":"const ok = await LiveDocumentSync.setWatchStatusForDocument(slug, docPath, watchStatus);\nif (!ok) showToast('Could not change watch status - document may have moved', 'warning');","preventionTips":["Confirm slug and docPath still exist (refresh the workspace tree).","Send watchStatus as a strict boolean matching the backend contract.","Verify the caller is a member of the workspace.","When statusText is empty (some 500s), rely on the static fallback and log the status code."],"tags":["api","workspace","live-sync","watch-status","error-handling"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}