{"record":{"id":"9999892ac91c4654","repo":"Mintplex-Labs/anything-llm","slug":"failed-to-embed-content","errorCode":null,"errorMessage":"Failed to embed content","messagePattern":"Failed to embed content","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"server/endpoints/browserExtension.js","lineNumber":123,"sourceCode":"          return;\n        }\n\n        const { failedToEmbed = [], errors = [] } = await Document.addDocuments(\n          workspace,\n          [documents[0].location],\n          user?.id\n        );\n\n        if (failedToEmbed.length > 0) {\n          response.status(500).json({ success: false, error: errors[0] });\n          return;\n        }\n\n        await Telemetry.sendTelemetry(\"browser_extension_embed_content\");\n        response.status(200).json({ success: true });\n      } catch (error) {\n        console.error(error);\n        response.status(500).json({ error: \"Failed to embed content\" });\n      }\n    }\n  );\n\n  app.post(\n    \"/browser-extension/upload-content\",\n    [validBrowserExtensionApiKey],\n    async (request, response) => {\n      try {\n        const { textContent, metadata } = reqBody(request);\n        const Collector = new CollectorApi();\n        const { success, reason } = await Collector.processRawText(\n          textContent,\n          metadata\n        );\n\n        if (!success) {\n          response.status(500).json({ success: false, error: reason });","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/3aec848f2885144aa8f1e53b9731a04310d5d558/server/endpoints/browserExtension.js#L105-L141","documentation":"Catch-all 500 for POST /browser-extension/embed-content: anything thrown past the handled branches lands here. The most realistic throw is documents[0].location when the collector reported success:true with an empty documents array (TypeError reading 'location' of undefined), since processRawText itself never throws; otherwise it wraps Document.addDocuments throwing outright (DB open failure) or Telemetry.sendTelemetry (blocked outbound network). Server logs hold the actual stack.","triggerScenarios":"Collector returns success with zero documents (edge-case extraction of the captured text); Telemetry.sendTelemetry throws on an air-gapped/egress-blocked server; addDocuments throws before returning its failedToEmbed structure (SQLite open/lock error).","commonSituations":"Hardened/air-gapped deployments without outbound telemetry access; collector/server version drift returning unexpected payload shapes; concurrent DB writers.","solutions":["Read server logs - console.error prints the real stack; 'Cannot read properties of undefined (reading ...location)' confirms the empty-documents edge case.","Restart server and collector together to eliminate version-drift payloads.","If the stack points at Telemetry, allow outbound requests or set the telemetry-disable env var for the server.","If you control the deployment, add the empty-documents guard shown in exampleFix."],"exampleFix":"// before\nconst { failedToEmbed = [], errors = [] } = await Document.addDocuments(\n  workspace,\n  [documents[0].location],\n  user?.id\n);\n// after\nif (!success || !Array.isArray(documents) || documents.length === 0) {\n  response.status(500).json({ success: false, error: \"Collector returned no documents\" });\n  return;\n}\nconst { failedToEmbed = [], errors = [] } = await Document.addDocuments(\n  workspace,\n  [documents[0].location],\n  user?.id\n);","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"const hasDocuments = (r: unknown): r is { success: true; documents: { location: string }[] } =>\n  typeof r === 'object' && r !== null && (r as any).success === true && Array.isArray((r as any).documents) && (r as any).documents.length > 0;","tryCatchPattern":"try {\n  const res = await embedContent(apiKey, payload);\n  if (!res.body?.success) logServerSide(res.requestId); // catch-all 500s need server logs\n} catch (e) {\n  // 500 'Failed to embed content' is opaque - surface the server's console.error stack to the operator\n  throw new Error('Embed content failed; inspect AnythingLLM server logs for the thrown stack');\n}","preventionTips":["Allow telemetry egress or disable it via env so Telemetry.sendTelemetry cannot abort a successful flow.","Run matching server/collector versions to keep the documents payload shape stable.","Watch for 'reading location of undefined' in logs - that is the empty-documents edge case."],"tags":["browser-extension","embed-content","http-500","catch-all","undefined-access"],"backgroundTag":null,"analyzedSha":"3aec848f2885144aa8f1e53b9731a04310d5d558","analyzedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}