Mintplex-Labs/anything-llm · warning · Error

res.statusText || "Error setting watch status for document."

Error message

res.statusText || "Error setting watch status for document."

What it means

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.

Source

Thrown at frontend/src/models/experimental/liveSync.js:46

        return res.json();
      })
      .then((res) => res?.queues || [])
      .catch((e) => {
        console.error(e);
        return [];
      });
  },

  // Should be in Workspaces but is here for now while in preview
  setWatchStatusForDocument: async function (slug, docPath, watchStatus) {
    return fetch(`${API_BASE}/workspace/${slug}/update-watch-status`, {
      method: "POST",
      headers: baseHeaders(),
      body: JSON.stringify({ docPath, watchStatus }),
    })
      .then((res) => {
        if (!res.ok) {
          throw new Error(
            res.statusText || "Error setting watch status for document."
          );
        }
        return true;
      })
      .catch((e) => {
        console.error(e);
        return false;
      });
  },
};

export default LiveDocumentSync;

View on GitHub (pinned to 526360e320)

Solutions

  1. Confirm slug and docPath still exist (refresh the workspace tree).
  2. Send watchStatus as a strict boolean matching the backend contract.
  3. Verify the caller is a member of the workspace.
  4. If statusText is empty, fall back to the static message and log the status code.

Example fix

// before
const ok = await LiveDocumentSync.setWatchStatusForDocument(slug, docPath, watchStatus);

// after
const ok = await LiveDocumentSync.setWatchStatusForDocument(slug, docPath, Boolean(watchStatus));
if (!ok) showToast('Could not change watch status - document may have moved', 'warning');
Defensive patterns

Strategy: validation

Validate before calling

function validateWatchArgs(slug, docPath, watchStatus) {
  if (!slug?.trim()) return 'slug is required';
  if (!docPath?.trim()) return 'docPath is required';
  if (typeof watchStatus !== 'boolean') return 'watchStatus must be boolean';
  return null;
}

Type guard

/** @param {unknown} r */
function isWatchResult(r) { return typeof r === 'boolean'; }

Try / catch

const ok = await LiveDocumentSync.setWatchStatusForDocument(slug, docPath, watchStatus);
if (!ok) showToast('Could not change watch status - document may have moved', 'warning');

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13). Data as JSON: /api/errors/47816a6b9300a5f4. Report an issue: GitHub.