{"record":{"id":"47a9976bf204c63a","repo":"Mintplex-Labs/anything-llm","slug":"not-found-47a997","errorCode":null,"errorMessage":"Not Found","messagePattern":"Not Found","errorType":"http","errorClass":null,"httpStatus":404,"severity":"info","filePath":"server/endpoints/experimental/liveSync.js","lineNumber":102,"sourceCode":"  // Should be in workspace routes, but is here for now.\n  app.post(\n    \"/workspace/:slug/update-watch-status\",\n    [\n      validatedRequest,\n      flexUserRoleValid([ROLES.admin, ROLES.manager]),\n      validWorkspaceSlug,\n      featureFlagEnabled(DocumentSyncQueue.featureKey),\n    ],\n    async (request, response) => {\n      try {\n        const { docPath, watchStatus = false } = reqBody(request);\n        const workspace = response.locals.workspace;\n\n        const document = await Document.get({\n          workspaceId: workspace.id,\n          docpath: docPath,\n        });\n        if (!document) return response.sendStatus(404).end();\n\n        await DocumentSyncQueue.toggleWatchStatus(document, watchStatus);\n        return response.status(200).end();\n      } catch (error) {\n        console.error(\"Error processing the watch status update:\", error);\n        return response.status(500).end();\n      }\n    }\n  );\n}\n\nmodule.exports = { liveSyncEndpoints };\n","sourceCodeStart":84,"sourceCodeEnd":115,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/endpoints/experimental/liveSync.js#L84-L115","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Confirm the document exists at the given docpath in the workspace before toggling watch.\nasync function documentExists(baseUrl, token, slug, docPath) {\n  const res = await fetch(`${baseUrl}/v1/workspace/${slug}/documents`, {\n    headers: { Authorization: `Bearer ${token}` }\n  });\n  if (!res.ok) return false;\n  const data = await res.json();\n  const docs = data?.localFiles?.items ?? data?.files ?? [];\n  return docs.some(d => d?.name === docPath || d?.path === docPath || d?.docpath === docPath);\n}","typeGuard":null,"tryCatchPattern":"// Treat 404 as 'document not ingested' and guide the user to import it.\nconst res = await fetch(`${baseUrl}/workspace/${slug}/update-watch-status`, {\n  method: \"POST\",\n  headers: { Authorization: `Bearer ${token}`, \"Content-Type\": \"application/json\" },\n  body: JSON.stringify({ docPath, watchStatus: true })\n});\nif (res.status === 404) {\n  console.warn(`Document '${docPath}' not found in workspace '${slug}'; ingest it first.`);\n  return;\n}","preventionTips":["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."],"tags":["live-sync","experimental","http-semantics","document","api"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}