Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

### Fixes

- Normalize Linux ARM64 architecture name for bundled sentry-cli binary lookup ([#1201](https://github.com/getsentry/sentry-android-gradle-plugin/pull/1201))

## 6.7.1

### Fixes
Expand Down
2 changes: 1 addition & 1 deletion plugin-build/download-sentry-cli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function prop {

base_url="$(prop 'repo')/releases/download/$(prop 'version')"
target_dir="src/main/resources/bin/"
PLATFORMS="Darwin-universal Linux-i686 Linux-x86_64 Linux-aarch64 Windows-i686"
PLATFORMS="Darwin-arm64 Darwin-x86_64 Linux-i686 Linux-x86_64 Linux-aarch64 Windows-i686"

rm -f $target_dir/sentry-cli-*
for plat in $PLATFORMS; do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,18 @@ internal object SentryCliProvider {
val osName = System.getProperty("os.name").toLowerCase(Locale.ROOT)
val osArch = System.getProperty("os.arch")
return when {
"mac" in osName -> "Darwin-universal"
"linux" in osName -> if (osArch == "amd64") "Linux-x86_64" else "Linux-$osArch"
"mac" in osName -> if (osArch == "aarch64") "Darwin-arm64" else "Darwin-x86_64"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: The architecture check for Apple Silicon is incomplete. It only checks for "aarch64" while native ARM JVMs report "arm64", causing the wrong binary to be selected.
Severity: HIGH

Suggested Fix

Update the condition to handle both "aarch64" and "arm64" for macOS, similar to how it's handled for Linux and Windows. Change if (osArch == "aarch64") to if (osArch == "aarch64" || osArch == "arm64").

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location:
plugin-build/src/main/kotlin/io/sentry/android/gradle/SentryCliProvider.kt#L136

Potential issue: On macOS with Apple Silicon (M1/M2/M3) and a native ARM64 JVM, the
system property `os.arch` is reported as `"arm64"`. The current code in `getCliSuffix()`
only checks if `osArch == "aarch64"`. This condition fails, causing the `else` branch to
incorrectly return `"Darwin-x86_64"` instead of `"Darwin-arm64"`. This will lead to
failures when trying to execute the Sentry CLI on modern Mac setups, as the wrong binary
architecture will be used.

Did we get this right? 👍 / 👎 to inform future reviews.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

macOS omits arm64 arch alias

Medium Severity

In getCliSuffix(), the macOS branch only treats os.arch aarch64 as Apple Silicon, while Linux and Windows in the same change map both arm64 and aarch64 to the bundled ARM CLI. If a Mac JVM reports arm64, the code picks Darwin-x86_64 instead of Darwin-arm64, so the wrong bundled sentry-cli may be used or missing.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 25139c1. Configure here.

"linux" in osName -> {
val normalizedArch =
when (osArch) {
"amd64",
"x86_64" -> "x86_64"
"arm64",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

isn't arm64 and aarch64 two separate binaries?

"aarch64" -> "aarch64"
else -> osArch
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

what about i686? Does that fall under else?

}
"Linux-$normalizedArch"
}
"win" in osName -> "Windows-i686.exe"
else -> null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,15 @@ class SentryCliProviderTest {
}

@Test
@WithSystemProperty(["os.name"], ["mac"])
fun `getCliSuffix on mac returns Darwin-universal`() {
assertEquals("Darwin-universal", getCliSuffix())
@WithSystemProperty(["os.name", "os.arch"], ["mac", "aarch64"])
fun `getCliSuffix on mac aarch64 returns Darwin-arm64`() {
assertEquals("Darwin-arm64", getCliSuffix())
}

@Test
@WithSystemProperty(["os.name", "os.arch"], ["mac", "x86_64"])
fun `getCliSuffix on mac x86_64 returns Darwin-x86_64`() {
assertEquals("Darwin-x86_64", getCliSuffix())
}

@Test
Expand All @@ -159,6 +165,24 @@ class SentryCliProviderTest {
assertEquals("Linux-x86_64", getCliSuffix())
}

@Test
@WithSystemProperty(["os.name", "os.arch"], ["linux", "x86_64"])
fun `getCliSuffix on linux x86_64 returns Linux-x86_64`() {
assertEquals("Linux-x86_64", getCliSuffix())
}

@Test
@WithSystemProperty(["os.name", "os.arch"], ["linux", "arm64"])
fun `getCliSuffix on linux arm64 returns Linux-aarch64`() {
assertEquals("Linux-aarch64", getCliSuffix())
}

@Test
@WithSystemProperty(["os.name", "os.arch"], ["linux", "aarch64"])
fun `getCliSuffix on linux aarch64 returns Linux-aarch64`() {
assertEquals("Linux-aarch64", getCliSuffix())
}

@Test
@WithSystemProperty(["os.name", "os.arch"], ["linux", "armV7"])
fun `getCliSuffix on linux armV7 returns Linux-armV7`() {
Expand Down