Skip to content

Conversation

bitsandfoxes
Copy link
Contributor

@bitsandfoxes bitsandfoxes commented Aug 27, 2025

Fixes #2195, #2170

Problem

I still fail to reproduce this on both macOS and Windows. But given that the issue is appending the upload task multiple times there are only two places where this could fail:

  1. The check whether the upload task is there is insufficient
    if (!gradleBuildFile.Contains("sentry.properties"))
  2. Removing the task is failing
    var regex = new Regex(Regex.Escape(SymbolUploadTaskStartComment) + ".*" + Regex.Escape(SymbolUploadTaskEndComment), RegexOptions.Singleline);
    gradleBuildFile = regex.Replace(gradleBuildFile, "");
    • A possible explanation the I can see is that the SDK fails to remove the entirety of the upload task. During the following build it fails to recognize the task already exists and erroneously appends another one.

Proposal

The SDK is needs to be more defensive about adding the upload task to the Gradle file and prevent duplicated appending.

  1. Check for the actual marker instead of the .properties
  2. Update the regex to non-greedy handle multiply added upload tasks. The SDK fails to properly remove the entire task due to regex.Replace not doing what we expect it to do?
  3. Add a sanity check before adding the task with proper logging how to unblock yourself

@@ -304,7 +304,7 @@ internal void SetupSymbolsUpload(string unityProjectPath, string gradleProjectPa
{
symbolsUpload.RemoveUploadFromGradleFile();

if (_options is { Il2CppLineNumberSupportEnabled: true })
if (_options is { Enabled: true, Il2CppLineNumberSupportEnabled: true })
Copy link
Contributor Author

@bitsandfoxes bitsandfoxes Aug 27, 2025

Choose a reason for hiding this comment

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

Unrelated but: To reduce logging noise when the SDK is disabled.

@@ -102,8 +103,6 @@ public DebugSymbolUpload(IDiagnosticLogger logger,

public void AppendUploadToGradleFile(string sentryCliPath)
{
RemoveUploadFromGradleFile();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This now happens outside and before calling this method. Added a sanity check before actually writing to disk.

@bitsandfoxes
Copy link
Contributor Author

@sentry review

Copy link

🔒 GenAI Consent Required

To enable PR review and test generation via Prevent, an organization admin needs to:

  1. Go to your Sentry organization settings
  2. Enable GenAI features for your organization
  3. Enable the PR Review and Test Generation toggle

Once enabled, you can re-trigger this review by commenting.

@bitsandfoxes
Copy link
Contributor Author

bugbot review

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

vaind
vaind previously requested changes Sep 1, 2025
@bitsandfoxes bitsandfoxes requested a review from vaind September 8, 2025 15:02
@bitsandfoxes bitsandfoxes dismissed vaind’s stale review September 10, 2025 15:13

Addressed the concern raised in regards to the regex being off.

@bitsandfoxes bitsandfoxes merged commit 306e92e into main Sep 10, 2025
20 checks passed
@bitsandfoxes bitsandfoxes deleted the fix/android-upload-task branch September 10, 2025 15:13
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.

Sentry 'Upload Symbols Task' is added on each build producing duplicate task build error
5 participants