{"record":{"id":"60ae2ca9552d01f6","repo":"Mintplex-Labs/anything-llm","slug":"internal-server-error-60ae2c","errorCode":null,"errorMessage":"Internal Server Error","messagePattern":"Internal Server Error","errorType":"http","errorClass":null,"httpStatus":500,"severity":"warning","filePath":"server/endpoints/extensions/index.js","lineNumber":34,"sourceCode":"    \"/ext/:repo_platform/branches\",\n    [\n      validatedRequest,\n      flexUserRoleValid([ROLES.admin, ROLES.manager]),\n      isSupportedRepoProvider,\n    ],\n    async (request, response) => {\n      try {\n        const { repo_platform } = request.params;\n        const responseFromProcessor =\n          await new CollectorApi().forwardExtensionRequest({\n            endpoint: `/ext/${repo_platform}-repo/branches`,\n            method: \"POST\",\n            body: request.body,\n          });\n        response.status(200).json(responseFromProcessor);\n      } catch (e) {\n        console.error(e);\n        response.sendStatus(500).end();\n      }\n    }\n  );\n\n  app.post(\n    \"/ext/:repo_platform/repo\",\n    [\n      validatedRequest,\n      flexUserRoleValid([ROLES.admin, ROLES.manager]),\n      isSupportedRepoProvider,\n    ],\n    async (request, response) => {\n      try {\n        const { repo_platform } = request.params;\n        const responseFromProcessor =\n          await new CollectorApi().forwardExtensionRequest({\n            endpoint: `/ext/${repo_platform}-repo`,\n            method: \"POST\",","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/endpoints/extensions/index.js#L16-L52","documentation":"HTTP 500 from the catch-all of POST /ext/:repo_platform/branches (fetch branch list for a git repo provider). The route calls new CollectorApi().forwardExtensionRequest(...). Critically, forwardExtensionRequest catches its own fetch errors and returns {success:false,reason} — it never rejects — and there is no Telemetry call on this route. So a collector/document-processor outage surfaces as a 200 with a failure body, NOT a 500. This catch therefore fires only on truly unexpected errors: a synchronous throw from the CollectorApi constructor (CommunicationKey init) or a JSON serialization fault.","triggerScenarios":"The CommunicationKey (shared secret with the collector) failing to initialize (missing/corrupt key material), or new EncryptionManager() throwing during request construction. A collector that is simply unreachable does NOT trigger this 500 — it returns 200 with success:false.","commonSituations":"Corrupt or missing COLLECTOR_API_KEY / communication key after a botched upgrade or restore; ENV misconfiguration that breaks key loading on boot; a code change to EncryptionManager that throws on instantiation.","solutions":["Distinguish: if the HTTP response is 200 with {success:false,reason:...}, the collector is unreachable/misconfigured — start/fix the collector service and check COLLECTOR_PORT. If the response is a true 500, inspect the server log for the constructor/EncryptionManager stack trace.","Ensure the communication key material is present and valid (regenerate if corrupted, then restart both server and collector so they share the key).","Confirm repo_platform is a supported provider (the isSupportedRepoProvider middleware already filters this).","Verify the collector service is running and reachable at the configured host/port."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// Health-check the collector before issuing extension calls.\nasync function collectorAlive(baseUrl, token) {\n  // There is no direct collector health route; use a lightweight extension probe and inspect the body.\n  return true; // placeholder — real check is the response shape below\n}","typeGuard":null,"tryCatchPattern":"// Distinguish a true 500 (key/construction fault) from 200 success:false (collector issue).\nconst res = await fetch(`${baseUrl}/ext/${repo_platform}/branches`, {\n  method: \"POST\",\n  headers: { Authorization: `Bearer ${token}`, \"Content-Type\": \"application/json\" },\n  body: JSON.stringify(payload)\n});\nif (res.status === 500) {\n  // CommunicationKey/EncryptionManager fault — check server logs, regenerate key.\n  throw new Error(`extension infra failure (500) — inspect server logs`);\n}\nconst body = await res.json();\nif (body?.success === false) {\n  // Collector unreachable/misconfigured — NOT a 500. Surface body.reason to the user.\n  return { ok: false, reason: body.reason };\n}\nreturn { ok: true, data: body };","preventionTips":["Do not treat a collector outage as a 500 — it returns 200 with {success:false,reason}; branch on response body, not just status.","Keep the communication key intact and shared between server and collector; regenerate and restart both if corrupted.","Validate repo_platform against the supported set before calling."],"tags":["extensions","collector","communication-key","express","api"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}