Skip to content

Conversation

@cameroncooke
Copy link

@cameroncooke cameroncooke commented Jan 23, 2026

Summary

  • Add a platform field with Literal type to AndroidInsightResults and AppleInsightResults models
  • This enables Pydantic discriminated union resolution in Sentry when parsing size analysis results

Background

Sentry's size analysis comparison code parses insight results using a union type AndroidInsightResults | AppleInsightResults. Without a discriminator field, Pydantic uses left-to-right validation order, which causes iOS insights to be incorrectly parsed as AndroidInsightResults, silently dropping iOS-specific fields like strip_binary and image_optimization.

By adding an explicit platform field, Sentry can use Field(discriminator="platform") to correctly resolve the union type based on the platform value in the JSON.

Changes

  • android.py: Add platform: Literal["android"] = "android" to AndroidInsightResults
  • apple.py: Add platform: Literal["apple"] = "apple" to AppleInsightResults

Deployment Notes

This change is backwards compatible. The new field will be included in size analysis JSON output. Sentry will be updated to use this field as a discriminator, with a fallback for old data that doesn't include it.

Co-Authored-By: Claude [email protected]

Add a Literal-typed platform field to AndroidInsightResults and
AppleInsightResults to enable Pydantic discriminated union resolution
in downstream consumers (Sentry). Without this field, Pydantic's
left-to-right union validation causes iOS insights to be incorrectly
parsed as AndroidInsightResults, silently dropping iOS-specific fields.

Co-Authored-By: Claude <[email protected]>
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.

2 participants