Skip to content

fix(android): Report missing properties file or keys when flavorAware is enabled#6031

Merged
antonis merged 2 commits intomainfrom
fix/android-flavor-aware-error-messages
Apr 22, 2026
Merged

fix(android): Report missing properties file or keys when flavorAware is enabled#6031
antonis merged 2 commits intomainfrom
fix/android-flavor-aware-error-messages

Conversation

@antonis
Copy link
Copy Markdown
Contributor

@antonis antonis commented Apr 22, 2026

📢 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring

📜 Description

When flavorAware is set in project.ext.sentryCli and the per-variant properties file is missing, or required keys are absent, sentry.gradle previously swallowed the FileNotFoundException (logging at info) and passed null values to sentry-cli. Gradle then failed with an opaque:

Illegal null value provided in this collection: [..., --url, null, --auth-token, null, ..., --org, null, --project, null]

This PR makes the error actionable:

  • Throws a GradleException naming the expected sentry-${variant}.properties path when the file is missing (flavor-aware only).
  • Collects missing required keys (auth.token / SENTRY_AUTH_TOKEN, defaults.org, defaults.project) and throws a single error listing them all alongside the file path.
  • Only appends --url when defaults.url is set, so sentry-cli falls back to its default instead of being handed null.
  • Non-flavor-aware path (the SENTRY_PROPERTIES env flow) is unchanged.

💡 Motivation and Context

Users hitting this flow today (see #2837 as an example of the cryptic surface error) have no indication of which file was expected or which key was missing. This change surfaces both directly.

Fixes #2839.

💚 How did you test it?

Parse check./gradlew :app:help on samples/react-native/android with the updated sentry.gradle symlinked via the yarn workspace: builds the task graph without errors.

Validation harness — built a standalone Gradle project that copies the exact validation block (same message strings, same control flow) and drives 8 scenarios. All pass:

# Scenario Expectation Result
A flavorAware=true, properties file missing GradleException naming the expected path and flavorAware PASS
B flavorAware=true, file present, only defaults.org missing GradleException reporting only that key, with file path PASS
C flavorAware=true, file fully populated Args contain --url, --auth-token, --org, --project with no nulls PASS
D flavorAware=true, auth.token absent but SENTRY_AUTH_TOKEN set Succeeds; --auth-token uses env value PASS
E flavorAware=true, all three required keys missing Single GradleException listing all three keys PASS
F flavorAware=true, defaults.url empty string --url flag omitted; required args still present PASS
G flavorAware=false, properties file missing No exception (existing silent behavior preserved) PASS
H flavorAware=false, file present No flavor-specific args added PASS

Not run locally: a full :app:bundleRelease against real Sentry infrastructure. The change is isolated to the doLast block inside the _SentryUpload_ task, and the scenarios above cover every branch touched. No Gradle/Groovy test harness exists in this repo to check these in automatically.

📝 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

🤖 Generated with Claude Code

… is enabled

When `flavorAware` is set and the per-variant properties file is missing,
or required keys (`auth.token`/`SENTRY_AUTH_TOKEN`, `defaults.org`,
`defaults.project`) are absent, sentry.gradle previously swallowed the
error and passed `null` values to sentry-cli, failing with an opaque
`Illegal null value provided in this collection`.

Validate the file and required keys up front and throw a `GradleException`
naming the expected path and any missing keys. Also only append `--url`
when `defaults.url` is set, so sentry-cli can fall back to its default.

Fixes #2839

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 22, 2026

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

Generated by 🚫 dangerJS against 8458b0a

Matches convention used by other entries under Unreleased.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@antonis
Copy link
Copy Markdown
Contributor Author

antonis commented Apr 22, 2026

@sentry review

@antonis
Copy link
Copy Markdown
Contributor Author

antonis commented Apr 22, 2026

@cursor review

Copy link
Copy Markdown

@cursor cursor Bot left a comment

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 8458b0a. Configure here.

@antonis antonis marked this pull request as ready for review April 22, 2026 12:14
@antonis antonis merged commit 9fa0a49 into main Apr 22, 2026
63 of 69 checks passed
@antonis antonis deleted the fix/android-flavor-aware-error-messages branch April 22, 2026 13:29
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.

Provide missing path or properties value when using flavors on Android

2 participants