fix(reactcompat): bound react-detect output - #772
Merged
Conversation
academo
marked this pull request as ready for review
August 20, 2026 17:13
academo
requested review from
andresmgot,
leventebalogh and
toddtreece
and
a lite review from Copilot
and removed request for
a team
August 20, 2026 17:13
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens the reactcompat analysis pass so @grafana/react-detect cannot cause oversized validator output, while still preserving useful diagnostics when the process fails or is killed.
Changes:
- Adds bounded stdout/stderr capture and truncated previews for
react-detectexecution failures. - Caps serialized React compatibility diagnostics to 32 KiB and emits a truncation summary when results exceed the limit.
- Tightens JSON parsing to require the expected
sourceCodeIssues/dependencyIssuesfields, with new tests covering truncation and malformed/partial outputs.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| pkg/analysis/passes/reactcompat/reactcompat.go | Implements bounded process output capture, stream previewing, diagnostic size limiting, and stricter react-detect JSON validation. |
| pkg/analysis/passes/reactcompat/reactcompat_test.go | Adds tests ensuring output stays within the report cap and that malformed/partial JSON is rejected. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+256
to
+260
| if len(fields.SourceCodeIssues) == 0 || len(fields.DependencyIssues) == 0 || | ||
| bytes.Equal(bytes.TrimSpace(fields.SourceCodeIssues), []byte("null")) || | ||
| bytes.Equal(bytes.TrimSpace(fields.DependencyIssues), []byte("null")) { | ||
| return nil, fmt.Errorf("parse react-detect output: missing required result fields") | ||
| } |
s4kh
approved these changes
Aug 20, 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.
Prevents failed or oversized
react-detectoutput from producing oversized validator results.Valid JSON is still reported after process failures. Serialized reports are capped at 32 KiB with omitted issue counts, and process output capture is bounded.