{"record":{"id":"b7a889a6ec4a1330","repo":"abhigyanpatwari/GitNexus","slug":"failed-to-enrich-cluster-community-id","errorCode":null,"errorMessage":"Failed to enrich cluster ${community.id}:","messagePattern":"Failed to enrich cluster (.+?):","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"gitnexus/src/core/ingestion/cluster-enricher.ts","lineNumber":133,"sourceCode":"        name: community.heuristicLabel,\n        keywords: [],\n        description: '',\n      });\n      continue;\n    }\n\n    try {\n      const prompt = buildEnrichmentPrompt(members, community.heuristicLabel);\n      const response = await llmClient.generate(prompt);\n\n      // Rough token estimate\n      tokensUsed += prompt.length / 4 + response.length / 4;\n\n      const enrichment = parseEnrichmentResponse(response, community.heuristicLabel);\n      enrichments.set(community.id, enrichment);\n    } catch (error) {\n      // On error, fallback to heuristic\n      logger.warn({ error }, `Failed to enrich cluster ${community.id}:`);\n      enrichments.set(community.id, {\n        name: community.heuristicLabel,\n        keywords: [],\n        description: '',\n      });\n    }\n  }\n\n  return { enrichments, tokensUsed };\n};\n\n// ============================================================================\n// BATCH ENRICHMENT (more efficient)\n// ============================================================================\n\n/**\n * Enrich multiple clusters in a single LLM call (batch mode)\n * More efficient for token usage but requires larger context window","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/aac7515d2a8c50a1f8f923c6fb77218b333560d6/gitnexus/src/core/ingestion/cluster-enricher.ts#L115-L151","documentation":"Cluster enrichment asks an injected LLMClient to generate a semantic name/description for each detected code community via llmClient.generate(prompt). If generate() rejects (transport/auth/rate-limit failure), the catch logs 'Failed to enrich cluster ${community.id}' and stores the community's heuristicLabel with empty keywords and description instead. Note that parseEnrichmentResponse already swallows malformed-JSON responses internally, so this warning almost always indicates the LLM API call itself failed, not response parsing.","triggerScenarios":"llmClient.generate throwing while enriching a community that has at least one member: invalid/expired API key, unreachable model endpoint, 429 rate limiting, request timeout, or exhausted quota.","commonSituations":"Running analyze with enrichment enabled but the LLM key env vars unset/expired; corporate proxy blocking the model API; free-tier rate limits hit on repos with many clusters; transient provider outages mid-run.","solutions":["Inspect the logged { error } field — 401/403 means key problem, 429 means rate limit, ECONNREFUSED/ETIMEDOUT means network","Verify and fix the LLM credentials/endpoint configuration your LLMClient was built with","For 429s, wait out the rate-limit window or reduce the number of clusters before re-running enrichment","Accept the automatic fallback — clusters keep their heuristic labels, which is a cosmetic (not structural) quality loss"],"exampleFix":"// before\nconst response = await llmClient.generate(prompt); // rejects mid-analyze -> warn + heuristic fallback\n\n// after: preflight once before the enrichment loop\ntry {\n  await llmClient.generate('Reply with {\"ok\":true}');\n} catch (e) {\n  console.error('LLM unreachable - enrichment will use heuristic labels:', e instanceof Error ? e.message : e);\n}","handlingStrategy":"fallback","validationCode":"// preflight before enrichClusters: prove the LLM endpoint works\nawait llmClient.generate('Reply with {\"ok\":true}').catch((e) => {\n  throw new Error(`LLM preflight failed - enrichment will degrade: ${e.message}`);\n});","typeGuard":null,"tryCatchPattern":"try {\n  const enrichment = parseEnrichmentResponse(await llmClient.generate(prompt), heuristicLabel);\n  enrichments.set(community.id, enrichment);\n} catch (error) {\n  enrichments.set(community.id, { name: heuristicLabel, keywords: [], description: '' }); // heuristic fallback\n}","preventionTips":["Configure and rotate the LLM API key via environment before running analyze with enrichment","Run the one-shot preflight generate() before a long analyze to fail fast with a clear cause","Watch the { error } field: 401/403 = key, 429 = back off, ETIMEDOUT/ECONNREFUSED = network","Accept heuristic labels as the designed degradation — enrichment quality, not index integrity, is lost"],"tags":["llm","enrichment","network","api-key","clustering"],"backgroundTag":"llm-api-call-failed","analyzedSha":"aac7515d2a8c50a1f8f923c6fb77218b333560d6","analyzedAt":"2026-08-20T23:29:22.980Z","contentChangedAt":"2026-08-20T23:29:22.980Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}