-
Notifications
You must be signed in to change notification settings - Fork 304
Use public Sentry org/project, env-injected token #5708
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mokagio
wants to merge
8
commits into
main
Choose a base branch
from
ainfra-2790-remove-sentryproperties-in-favor-of-public-values-and-env
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c51c173
Use public Sentry org/project, env-injected token
mokagio e11c0ea
Guard all sentry-cli tasks on a non-blank token
mokagio 0f7d6d9
Remove verbose AI comments
mokagio 527d95b
Delete unused `sentry.properties.enc`
mokagio 9193ab2
Keep the Sentry auth token lazy
mokagio d4c2b86
Revert "Keep the Sentry auth token lazy"
mokagio 829a341
Trim the Sentry auth token before using it
mokagio f981a32
Say "or is blank" in the auth token guard
mokagio File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
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
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
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why this assignment is needed if you already have it above?
You could also keep the fact that it exists or not like
val hasSentryAuthToken = providers.environmentVariable("SENTRY_AUTH_TOKEN").map { it.isNotBlank() }.orElse(false)or similar.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adopted the Provider form in 5dad760, but kept the assignment — it's load-bearing.
Checking the 6.16.0 plugin jar:
SentryPluginExtension.authTokenisobjects.property(String::class.java).convention(null as String?). It has no environment default, so withoutauthToken = …the extension property stays absent.SentryCliExecTaskthen goes the other way — it exportsSENTRY_AUTH_TOKENinto thesentry-cliprocess from that property. And the extension value isn't only used for that:SentryOrgValueSource,SentryTelemetryService, and the source-bundle/native-symbol registration read it too.So
sentry-clipicking the token up "for free" would rely on it happening to be in the Gradle daemon's inherited environment, which is stale whenever the daemon outlives the shell that started it. The explicit assignment makes it deterministic.Your second point stands on its own though, so I took it:
Same single source for the bound value and the guard, but lazy now — a build that never configures Sentry never resolves the variable. I used
filter { it.isNotBlank() }rather thanmap { … }.orElse(false)so the one provider serves both roles; a blank value stays absent instead of reaching the plugin as"".Verified against the three env states (unset / set-but-empty / set), with configuration cache on: the extension property reads
<absent>,<absent>,dummy-token, and the guard throws, throws, passes.Posted by Claude Code (Opus 5) on behalf of @mokagio with approval.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correcting myself — I've reverted the provider refactor in 3ad15ee, so this is back to the
String?val you commented on.The refactor was a local improvement that made this repo the odd one out. The same migration already merged elsewhere with the eager read:
WordPress/build.gradle:71,def sentryAuthToken = providers.environmentVariable("SENTRY_AUTH_TOKEN").orNull?.trim() ?: null, bound withauthToken = sentryAuthTokenand guarded withif (sentryAuthToken == null)onSentryCliExecTask. Same shape as here.Simplenote/build.gradle:77,authToken = providers.environmentVariable("SENTRY_AUTH_TOKEN").orNull(no guard).The point of this migration is one pattern across the fleet, so consistency wins over the marginally nicer form here.
On the assignment itself: it is needed. In the 6.16.0 plugin jar,
SentryPluginExtension.authTokenisobjects.property(String::class.java).convention(null as String?)— no environment default.SentryCliExecTaskgoes the other way, exportingSENTRY_AUTH_TOKENinto thesentry-cliprocess from that property, andSentryOrgValueSource/SentryTelemetryServiceread it too. Without the assignment we'd be relying on the token happening to sit in the Gradle daemon's inherited environment, which is stale whenever the daemon outlives the shell that started it.Why
takeIf { it.isNotBlank() }here rather than WordPress-Android's?.trim() ?: null: that form relies on Groovy truth, where"" ?: nullisnull. In Kotlin the elvis only fires onnull, so a set-but-empty variable would sail through as"". Verified both against the four env states — unset, empty, whitespace, real — and they agree.Posted by Claude Code (Opus 5) on behalf of @mokagio with approval.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@iangmaia real Gio here, not a meat proxy.
I updated the implementation in 829a341 and aligned it with the other apps that already do this.
My understanding is that the
val sentryAuthToken =assigns the token from the env if any making it available to the other steps. TheauthToken = sentryAuthTokenis what passes it to the Sentry plugin itself.