fix: three bug fixes — xcode report JSON.parse, upgrade response.json(), seer schema validation - #1349
Draft
cursor[bot] wants to merge 3 commits into
Draft
fix: three bug fixes — xcode report JSON.parse, upgrade response.json(), seer schema validation#1349cursor[bot] wants to merge 3 commits into
cursor[bot] wants to merge 3 commits into
Conversation
…LI-RN-XCODE) Co-authored-by: Miguel Betegón <miguelbetegongarcia@gmail.com>
…CLI-UPGRADE) Co-authored-by: Miguel Betegón <miguelbetegongarcia@gmail.com>
…LI-SEER) Co-authored-by: Miguel Betegón <miguelbetegongarcia@gmail.com>
Contributor
|
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.
Summary
Three defensive bug fixes for crash-prone code paths discovered via codebase analysis.
1.
fix(react-native): guard JSON.parse of sourcemap report fileRoot cause: In
src/commands/react-native/xcode.ts,JSON.parse(readFileSync(reportPath))is called on a file written by an external React Native subprocess. If the subprocess crashes or exits before writing the report, this throws an unhelpful ENOENT or SyntaxError.Reproduction: Trigger an Xcode build where the Metro bundler script fails before writing
sourcemap-report.json(e.g., Metro crash, Hermes misconfiguration, build timeout).Fix: Wrap in try/catch, log at debug level, and return
{ status, pair: null }— the same graceful fallback used when the report lacks required fields.2.
fix(upgrade): wrap response.json() to catch non-JSON responsesRoot cause: In
src/lib/upgrade.ts,fetchLatestFromGitHubandfetchLatestFromNpmcallresponse.json()after checkingresponse.ok, but a CDN outage or corporate proxy can return HTML with a 200 status code. The resulting SyntaxError escapes as an unhandled exception.Reproduction: Run
sentry cli upgradebehind a corporate proxy that serves a login page at 200 OK, or during a CDN outage returning HTML.Fix: Wrap
response.json()in try/catch and throw a properUpgradeError('network_error', ...)with descriptive messages.3.
fix(seer): validate autofix response with existing Zod schemaRoot cause: In
src/lib/api/seer.ts,getAutofixStatecallsapiRequestToRegion<AutofixResponse>without passing the existingAutofixResponseSchema. If the API returns malformed data, the code crashes when accessingdata.autofixproperties instead of failing with a schema validation error.Reproduction: Call
sentry issue explainwhen the Seer API returns an unexpected response shape (e.g., during a deploy with schema changes).Fix: Pass
schema: AutofixResponseSchematoapiRequestToRegion, enabling runtime validation using the already-defined Zod schema.