Skip to content

fix(android): Accept RegularFile in Gradle bundle task path guards#6320

Merged
antonis merged 2 commits into
mainfrom
fix/android-sourcemap-regularfile-guard
Jun 19, 2026
Merged

fix(android): Accept RegularFile in Gradle bundle task path guards#6320
antonis merged 2 commits into
mainfrom
fix/android-sourcemap-regularfile-guard

Conversation

@antonis

@antonis antonis commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

📢 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring

📜 Description

The Kotlin rewrite of the Gradle integration (sentry.gradle.kts, shipped in 8.14.0 via #6119) guards the bundle task path properties with a strict is org.gradle.api.file.Directory check in extractBundleTaskArguments, returning all-null otherwise:

val intermediateSourcemapsDirFile =
    when (jsIntermediateSourceMapsDir) {
        is org.gradle.api.file.Directory -> jsIntermediateSourceMapsDir.asFile
        else -> return BundleTaskArgs(null, null, null, null)   // ← bails out
    }

React Native's BundleHermesCTask declares jsIntermediateSourceMapsDir as a RegularFileProperty (it holds a directory path but mkdirs() is called on it), so .orNull resolves to a RegularFile, the is Directory branch is skipped, and the function returns all-null. The caller then logs [sentry] Could not extract bundle task arguments for '…'. Source maps will not be uploaded. and silently skips the upload.

The legacy fallback (extractBundleTaskArgumentsLegacy) can't rescue it because the modern BundleHermesCTask is a plain DefaultTask with no command-line args. The previous Groovy script read the path untyped (props.jsIntermediateSourceMapsDir.get().asFile.absolutePath), which is why this only regressed with the Kotlin rewrite.

This PR makes all three guards accept both Directory and RegularFile.

Scope note

The linked issue attributes this to RN 0.85, but jsIntermediateSourceMapsDir has been a RegularFileProperty for much longer — verified in RN 0.80.1 and 0.86.0. So the regression affects a wide range of RN versions on SDK 8.14.0+, not just 0.85.

💡 Motivation and Context

Fixes #6319. Without source map upload, production Hermes stack traces are never symbolicated.

💚 How did you test it?

No automated test was added — the affected code lives in an apply from: Gradle script, so its top-level functions aren't reachable from a unit test, and the only faithful coverage (Gradle TestKit applying the real script) is disproportionate infrastructure for a type-guard fix and isn't part of the current TS/Jest CI.

Verification is manual: on a release Android build with a RN version whose BundleHermesCTask.jsIntermediateSourceMapsDir is a RegularFileProperty (e.g. 0.80–0.86) and SENTRY_AUTH_TOKEN set, confirm sentry-cli sourcemaps upload runs and an artifact bundle with a matching Debug ID appears under Project → Settings → Source Maps, instead of the "Could not extract bundle task arguments" warning.

📝 Checklist

  • I added tests to verify 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.
  • All tests passing
  • No breaking changes

🔮 Next steps

Consider adding Gradle-level test coverage (e.g. TestKit) for sentry.gradle.kts to catch bundle-task extraction regressions in the future.

🤖 Generated with Claude Code

The Kotlin rewrite of the Gradle integration (sentry.gradle.kts) guarded
bundle task path properties with `is Directory`, falling back to all-null
otherwise. React Native's BundleHermesCTask declares
`jsIntermediateSourceMapsDir` as a `RegularFileProperty`, so `.orNull`
resolves to a `RegularFile`, the guard bails out, and source map upload is
silently skipped with "Could not extract bundle task arguments".

Accept both `Directory` and `RegularFile` in all three guards.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Semver Impact of This PR

None (no version bump detected)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


  • fix(android): Accept RegularFile in Gradle bundle task path guards by antonis in #6320

🤖 This preview updates automatically when you update the PR.

@github-actions

github-actions Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor
Fails
🚫 Pull request is not ready for merge, please add the "ready-to-merge" label to the pull request

Generated by 🚫 dangerJS against 6ebdc24

@antonis antonis added the ready-to-merge Triggers the full CI test suite label Jun 18, 2026
@antonis

antonis commented Jun 18, 2026

Copy link
Copy Markdown
Contributor Author

@cursor review

@antonis

antonis commented Jun 18, 2026

Copy link
Copy Markdown
Contributor Author

@sentry review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 308504e. Configure here.

@sentry

sentry Bot commented Jun 18, 2026

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
Sentry RN io.sentry.reactnative.sample 8.15.0 (92) Release

⚙️ sentry-react-native Build Distribution Settings

@github-actions

Copy link
Copy Markdown
Contributor

Android (legacy) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 444.96 ms 498.72 ms 53.76 ms
Size 49.74 MiB 54.81 MiB 5.07 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
44c8b3f+dirty 414.20 ms 457.28 ms 43.08 ms
37a2091+dirty 407.82 ms 441.22 ms 33.40 ms
580fb5c+dirty 436.34 ms 471.63 ms 35.28 ms
0bd8916+dirty 412.77 ms 451.31 ms 38.54 ms
5a010b7+dirty 425.62 ms 469.38 ms 43.76 ms
7d8c8bd+dirty 417.45 ms 462.10 ms 44.65 ms
5fe1c6c+dirty 401.62 ms 445.28 ms 43.66 ms
5b7e8a7+dirty 418.55 ms 488.46 ms 69.91 ms
6177334+dirty 408.16 ms 441.14 ms 32.98 ms
b9bebee+dirty 438.86 ms 452.21 ms 13.35 ms

App size

Revision Plain With Sentry Diff
44c8b3f+dirty 48.30 MiB 53.46 MiB 5.15 MiB
37a2091+dirty 48.30 MiB 53.58 MiB 5.28 MiB
580fb5c+dirty 49.74 MiB 54.79 MiB 5.05 MiB
0bd8916+dirty 48.30 MiB 53.57 MiB 5.26 MiB
5a010b7+dirty 48.30 MiB 53.58 MiB 5.28 MiB
7d8c8bd+dirty 48.30 MiB 53.54 MiB 5.23 MiB
5fe1c6c+dirty 43.75 MiB 48.14 MiB 4.39 MiB
5b7e8a7+dirty 48.30 MiB 53.58 MiB 5.28 MiB
6177334+dirty 48.30 MiB 53.54 MiB 5.23 MiB
b9bebee+dirty 48.30 MiB 53.58 MiB 5.28 MiB

@github-actions

Copy link
Copy Markdown
Contributor

Android (new) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 422.35 ms 441.61 ms 19.27 ms
Size 49.74 MiB 54.81 MiB 5.07 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
a50b33d+dirty 353.21 ms 398.48 ms 45.27 ms
7d6fd3a+dirty 435.06 ms 458.78 ms 23.72 ms
37a2091+dirty 429.71 ms 477.00 ms 47.29 ms
580fb5c+dirty 515.72 ms 585.38 ms 69.66 ms
0bd8916+dirty 400.15 ms 442.72 ms 42.57 ms
5a010b7+dirty 475.15 ms 519.02 ms 43.88 ms
7d8c8bd+dirty 406.06 ms 460.88 ms 54.81 ms
890d145+dirty 486.42 ms 514.85 ms 28.43 ms
5b7e8a7+dirty 601.58 ms 634.98 ms 33.40 ms
6177334+dirty 404.80 ms 456.74 ms 51.94 ms

App size

Revision Plain With Sentry Diff
a50b33d+dirty 43.94 MiB 48.94 MiB 5.00 MiB
7d6fd3a+dirty 43.94 MiB 49.00 MiB 5.06 MiB
37a2091+dirty 48.30 MiB 53.58 MiB 5.28 MiB
580fb5c+dirty 49.74 MiB 54.79 MiB 5.05 MiB
0bd8916+dirty 48.30 MiB 53.57 MiB 5.26 MiB
5a010b7+dirty 48.30 MiB 53.58 MiB 5.28 MiB
7d8c8bd+dirty 48.30 MiB 53.54 MiB 5.23 MiB
890d145+dirty 43.94 MiB 49.00 MiB 5.06 MiB
5b7e8a7+dirty 48.30 MiB 53.58 MiB 5.28 MiB
6177334+dirty 48.30 MiB 53.54 MiB 5.23 MiB

Comment thread CHANGELOG.md Outdated
@antonis antonis removed the ready-to-merge Triggers the full CI test suite label Jun 19, 2026
@antonis antonis marked this pull request as ready for review June 19, 2026 07:40
@antonis antonis merged commit 0785c3b into main Jun 19, 2026
54 of 66 checks passed
@antonis antonis deleted the fix/android-sourcemap-regularfile-guard branch June 19, 2026 08:01
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.

[Android] Gradle source map upload silently skipped on react-native 0.85 since 8.14.0

2 participants