Mintplex-Labs/anything-llm · info

Not Found

Error message

Not Found

What it means

HTTP 404 'Not Found' returned intentionally (NOT an exception) by POST /workspace/:slug/update-watch-status when Document.get({workspaceId, docpath:docPath}) returns null. This is the live-sync (experimental) watch-toggle route, gated by the DocumentSyncQueue feature flag and admin/manager role. The 404 means no document matches the given docPath inside the workspace — expected control flow, not a server fault.

Source

Thrown at server/endpoints/experimental/liveSync.js:102

  // Should be in workspace routes, but is here for now.
  app.post(
    "/workspace/:slug/update-watch-status",
    [
      validatedRequest,
      flexUserRoleValid([ROLES.admin, ROLES.manager]),
      validWorkspaceSlug,
      featureFlagEnabled(DocumentSyncQueue.featureKey),
    ],
    async (request, response) => {
      try {
        const { docPath, watchStatus = false } = reqBody(request);
        const workspace = response.locals.workspace;

        const document = await Document.get({
          workspaceId: workspace.id,
          docpath: docPath,
        });
        if (!document) return response.sendStatus(404).end();

        await DocumentSyncQueue.toggleWatchStatus(document, watchStatus);
        return response.status(200).end();
      } catch (error) {
        console.error("Error processing the watch status update:", error);
        return response.status(500).end();
      }
    }
  );
}

module.exports = { liveSyncEndpoints };

View on GitHub (pinned to 526360e320)

Solutions

  1. Confirm the document exists in the workspace via GET /v1/workspace/:slug/documents or the admin documents list, and use the exact docpath shown.
  2. Ensure the document has been ingested (embedded) — watch only applies to documents present in the documents table.
  3. Verify the experimental_live_file_sync feature flag is enabled, otherwise the route is blocked earlier by middleware.
  4. If the document genuinely should exist, re-ingest it into the workspace.
Defensive patterns

Strategy: validation

Validate before calling

// Confirm the document exists at the given docpath in the workspace before toggling watch.
async function documentExists(baseUrl, token, slug, docPath) {
  const res = await fetch(`${baseUrl}/v1/workspace/${slug}/documents`, {
    headers: { Authorization: `Bearer ${token}` }
  });
  if (!res.ok) return false;
  const data = await res.json();
  const docs = data?.localFiles?.items ?? data?.files ?? [];
  return docs.some(d => d?.name === docPath || d?.path === docPath || d?.docpath === docPath);
}

Try / catch

// Treat 404 as 'document not ingested' and guide the user to import it.
const res = await fetch(`${baseUrl}/workspace/${slug}/update-watch-status`, {
  method: "POST",
  headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json" },
  body: JSON.stringify({ docPath, watchStatus: true })
});
if (res.status === 404) {
  console.warn(`Document '${docPath}' not found in workspace '${slug}'; ingest it first.`);
  return;
}

Prevention

When it happens

Trigger: Sending a docPath that does not correspond to any document in the workspace (wrong path, document never imported, document deleted). Also reached if live file sync moved/renamed the file so the stored docpath no longer matches.

Common situations: Enabling watch on a document before it has been embedded/ingested; passing a filesystem absolute path instead of the stored relative docpath; the document was removed but the UI still lists it.

Related errors


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