Skip to content

fix(insight): handle individual LLM failures in qualitative insights (#2341)#2361

Merged
DragonnZhang merged 1 commit intoQwenLM:mainfrom
netbrah:fix/insight-partial-qualitative
Mar 14, 2026
Merged

fix(insight): handle individual LLM failures in qualitative insights (#2341)#2361
DragonnZhang merged 1 commit intoQwenLM:mainfrom
netbrah:fix/insight-partial-qualitative

Conversation

@netbrah
Copy link
Copy Markdown
Contributor

@netbrah netbrah commented Mar 13, 2026

Fixes #2341

Root Cause

generateQualitativeInsights runs 8 parallel LLM calls via Promise.all. The inner generate helper re-throws errors, so a single LLM call failure (timeout, rate limit, JSON parse error) rejects the entire Promise.all, catches at the outer try/catch, and returns undefined for the whole qualitative object.

In the React report, every detailed section is gated by {data.qualitative && (...)} — so when qualitative is undefined, all sections disappear. Only the header and stats row survive.

Fix

  • DataProcessor.ts: Changed the generate helper to catch errors and return undefined instead of re-throwing. Individual LLM call failures no longer crash the entire qualitative section — surviving calls still populate their sections.
  • QualitativeInsightTypes.ts: Made all fields on QualitativeInsights optional so partial results are type-safe.
  • Each React section component already handles missing data (if (!field) return null), so no frontend changes needed.

Test

Added 3 unit tests:

  • Partial failure: some LLM calls fail → qualitative is defined, failed sections are undefined, successful sections populate
  • Empty facets: returns undefined as before
  • Full success: all 8 calls succeed, qualitative is complete

Made with Cursor

…(#2341)

Previously, `generateQualitativeInsights` used `Promise.all` with a
`generate` helper that re-threw errors. A single LLM call failure
(timeout, rate limit, JSON parse error) caused the entire `qualitative`
object to become `undefined`, hiding all detailed report sections.

Now individual `generate` calls catch errors and return `undefined`
instead of throwing. The `QualitativeInsights` interface fields are
made optional so partial results render correctly — each React section
component already guards against missing data with `if (!field) return
null`.

Made-with: Cursor
Copy link
Copy Markdown
Collaborator

@DragonnZhang DragonnZhang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

/insight command generates incomplete HTML report — only header section visible, missing detailed content sections

2 participants