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
- Confirm the document exists in the workspace via GET /v1/workspace/:slug/documents or the admin documents list, and use the exact docpath shown.
- Ensure the document has been ingested (embedded) — watch only applies to documents present in the documents table.
- Verify the experimental_live_file_sync feature flag is enabled, otherwise the route is blocked earlier by middleware.
- 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
- Use the exact stored docpath (relative, not absolute filesystem path) when toggling watch.
- Ensure the document is ingested/embedded before enabling live-sync watch.
- Confirm the experimental_live_file_sync feature flag is enabled.
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
- Could not update status.
- Could not update agent plugin status.
- Could not update agent plugin config.
- Could not delete agent plugin config.
- res.statusText || "Error setting watch status for document."
AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13).
Data as JSON: /api/errors/47a9976bf204c63a.
Report an issue: GitHub.