Skip to content

fix: Annotate nullable array returns on the array, not the element - #6558

Merged
runningcode merged 2 commits into
mainfrom
no/jetbrains-nullable-array-returns
Nov 18, 2026
Merged

runningcode merged 2 commits into
mainfrom
no/jetbrains-nullable-array-returns

Conversation

@runningcode

@runningcode runningcode commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

📜 Description

Moves the JetBrains @Nullable from the element type to the array on six public methods that return a nullable array:

💡 Motivation and Context

JetBrains @Nullable is a TYPE_USE annotation, so @Nullable byte[] marks the element type, not the array. Kotlin saw these returns as ByteArray and Array<String>, although they can return null. With byte @Nullable [] Kotlin sees ByteArray? and Array<String>?.

Follow-up to the review on #6497, which fixed the same thing on ViewHierarchyEventProcessor.snapshotViewHierarchyAsData. The ScreenshotUtils returns use androidx.annotation.Nullable, a declaration annotation that Kotlin already reads as a nullable return, so they stay as they are.

💚 How did you test it?

A Kotlin assignment of each kind of return to a non-null type now fails to compile. The Kotlin tests of the modules that call these methods still compile, and their unit tests pass.

📝 Checklist

  • I added GH Issue ID & Linear ID
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.
  • Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec.

🔮 Next steps

Kotlin code that uses these returns as non-null, for example attachment.bytes.size, no longer compiles until it handles null.

🤖 Generated with Claude Code

@sentry

sentry Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
SDK Size io.sentry.tests.size 8.65.0 (1) release

⚙️ sentry-android Build Distribution Settings

@runningcode
runningcode marked this pull request as ready for review November 11, 2026 14:28
@runningcode
runningcode requested review from a team and adinauer as code owners November 11, 2026 14:28
@runningcode
runningcode requested review from 0xadam-brown and markushi and removed request for a team November 11, 2026 14:28
@runningcode runningcode added the ship-it PR is ready to merge from a reviewer perspective label Nov 11, 2026

@0xadam-brown 0xadam-brown left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the follow-up!

runningcode and others added 2 commits November 18, 2026 09:27
JetBrains @nullable is a TYPE_USE annotation, so @nullable byte[] marks
the element type and Kotlin saw ByteArray instead of ByteArray?. Moving
it to byte @nullable [] makes Kotlin see the nullable return.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@runningcode
runningcode force-pushed the no/jetbrains-nullable-array-returns branch from 70090b1 to e6b85e7 Compare November 18, 2026 08:27
@runningcode
runningcode enabled auto-merge (squash) November 18, 2026 08:28
@github-actions github-actions Bot added the risk: medium PR risk score: medium label Nov 18, 2026
@runningcode
runningcode merged commit 788975f into main Nov 18, 2026
46 of 47 checks passed
@runningcode
runningcode deleted the no/jetbrains-nullable-array-returns branch November 18, 2026 08:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium ship-it PR is ready to merge from a reviewer perspective

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants