fix(insight): handle individual LLM failures in qualitative insights (#2341)#2361
Merged
DragonnZhang merged 1 commit intoQwenLM:mainfrom Mar 14, 2026
Merged
Conversation
…(#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
This was referenced Mar 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2341
Root Cause
generateQualitativeInsightsruns 8 parallel LLM calls viaPromise.all. The innergeneratehelper re-throws errors, so a single LLM call failure (timeout, rate limit, JSON parse error) rejects the entirePromise.all, catches at the outertry/catch, and returnsundefinedfor the wholequalitativeobject.In the React report, every detailed section is gated by
{data.qualitative && (...)}— so whenqualitativeisundefined, all sections disappear. Only the header and stats row survive.Fix
DataProcessor.ts: Changed thegeneratehelper to catch errors and returnundefinedinstead 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 onQualitativeInsightsoptional so partial results are type-safe.if (!field) return null), so no frontend changes needed.Test
Added 3 unit tests:
qualitativeis defined, failed sections areundefined, successful sections populateundefinedas beforequalitativeis completeMade with Cursor