Skip to content

Conversation

@NINNiT
Copy link

@NINNiT NINNiT commented Dec 15, 2025

feat: add option to ignore source bundle upload failures

📜 Description

If a self-hosted sentry instance is unreachable, the build fails during the source bundle upload step, blocking the entire build process. This is an initial solution to optionally ignore failures while uploading source maps.

It adds the property ignoreSourceBundleUploadFailure, which is set to false by default. (same behavior as before, should thus be a non-breaking change):

      <plugin>
        <groupId>io.sentry</groupId>
        <artifactId>sentry-maven-plugin</artifactId>
        <configuration>
          <ignoreSourceBundleUploadFailure>false</ignoreSourceBundleUploadFailure>
          [...]
        </configuration>
      </plugin>

💡 Motivation and Context

We're on a self-hosted sentry instance and it might have downtime at one point or another (upgrades, full backups, ...).
Source bundles are optional metadata for debugging - they shouldn't create a single point of failure for pipelines.

💚 How did you test it?

  • Added a new Integration Test to UploadSourceBundleTestIT.kt
  • Installed the plugin to a local maven repository, used it in a spring-boot app. Set sentry host to something non-existing. Confirmed that the property works and mvn package on the app finishes successfully, even though the source-bundle upload itself is failing.

📝 Checklist

  • I added GH Issue ID & Linear ID
  • I reviewed the submitted code
  • I added tests to verify the changes
  • I updated the docs if needed
  • No breaking changes

🔮 Next steps

  • Feel free to add suggestions / changes! This is just an initial draft, but should already be usable.

  • Docs would have to be updated

  • I'm not sure if the test is as clean as it could be, but we somehow have to induce a failure while uploading to the mocked python integration server...

   @Test
    fun `does not fail build when upload fails and ignoreSourceBundleUploadFailure is true`() {
        val baseDir = setupProject()
        val cliPath = File(baseDir, "sentry-cli-fail")
        cliPath.writeText(
            """
            #!/bin/sh
            if echo "$@" | grep -q "upload"; then
              exit 1
            fi
            exit 0
            """,
        )
        cliPath.setExecutable(true)

        val path = getPOM(baseDir, sentryCliPath = cliPath.absolutePath, ignoreSourceBundleUploadFailure = true)
        val verifier = Verifier(path)
        verifier.isAutoclean = false
        verifier.executeGoal("install")

        verifier.verifyTextInLog("Source bundle upload failed, ignored by configuration")

        verifier.resetStreams()
    }

@lbloder
Copy link
Collaborator

lbloder commented Dec 17, 2025

Hi @NINNiT,
Thank you for your contribution.

We should be able to finish the review of this PR on Friday

Copy link
Collaborator

@lbloder lbloder left a comment

Choose a reason for hiding this comment

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

Thank you @NINNiT for your contribution.
Looks good code-wise. Added a few suggestions on how to improve the test so it tests a scenario that is closer to the real world.


verifier.resetStreams()
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

Add a test to confirm that if the flag is set to false the build fails (i.e. old behaviour):

Suggested change
@Test
fun `fails build when upload fails and ignoreSourceBundleUploadFailure is false`() {
val baseDir = setupProject()
val path = getPOM(baseDir, sentryUrl = "http://unknown")
val verifier = Verifier(path)
verifier.isAutoclean = false
assertThrows(VerificationException::class.java) {
verifier.executeGoal("install")
}
verifier.verifyTextInLog("Could not resolve hostname (Could not resolve host: unknown)")
}

Copy link
Author

Choose a reason for hiding this comment

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

assertThrows wasn't available, but

        assertFailsWith<VerificationException> {
            verifier.executeGoal("install")
        }

seems to do just fine.

uses sentryUrl property set to unknown instead of wonky custom sh script
to force failure condition
@NINNiT
Copy link
Author

NINNiT commented Dec 26, 2025

@lbloder
Thanks for the input, i implemented your suggestions.
Test is miles cleaner this way... 🐵

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.

Allow optional failure on uploadSourceBundle

2 participants