fix(snapshots): Generate Paparazzi 1.x compatible snapshot test code#1142
Merged
runningcode merged 3 commits intomainfrom Apr 13, 2026
Merged
fix(snapshots): Generate Paparazzi 1.x compatible snapshot test code#1142runningcode merged 3 commits intomainfrom
runningcode merged 3 commits intomainfrom
Conversation
The generated ComposablePreviewSnapshotTest called HtmlReportWriter(maxPercentDifference=...) which only compiles against Paparazzi 2.x. In 1.x, HtmlReportWriter has no maxPercentDifference parameter and accepts a no-arg constructor instead. Detect the Paparazzi version from the declared testImplementation dependencies and conditionally generate the appropriate HtmlReportWriter constructor call for each major version. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
Semver Impact of This PR🟢 Patch (bug fixes) 📋 Changelog PreviewThis is how your changes will appear in the changelog. This PR will not appear in the changelog. 🤖 This preview updates automatically when you update the PR. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Unparseable version crashes instead of using fallback default
- Wrapped SemVer.parse in a try-catch block to return the default value 2 when version parsing fails, preventing IllegalArgumentException crashes for unparseable versions like dynamic version ranges.
Or push these changes by commenting:
@cursor push 9482252459
Preview (9482252459)
diff --git a/plugin-build/src/main/kotlin/io/sentry/android/gradle/AndroidComponentsConfig.kt b/plugin-build/src/main/kotlin/io/sentry/android/gradle/AndroidComponentsConfig.kt
--- a/plugin-build/src/main/kotlin/io/sentry/android/gradle/AndroidComponentsConfig.kt
+++ b/plugin-build/src/main/kotlin/io/sentry/android/gradle/AndroidComponentsConfig.kt
@@ -500,7 +500,13 @@
val dep = project.configurations.findByName("testImplementation")
?.allDependencies
?.find { it.group == "app.cash.paparazzi" && it.name == "paparazzi" }
- dep?.version?.let { SemVer.parse(it).major } ?: 2
+ dep?.version?.let {
+ try {
+ SemVer.parse(it).major
+ } catch (e: IllegalArgumentException) {
+ 2
+ }
+ } ?: 2
}
val generateTask =This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 0633ad4. Configure here.
Extract version parsing into a testable parseMajorVersion() function that takes the leading digits from the version string instead of requiring strict semver. This handles dynamic versions like "1.+" which SemVer.parse() would reject, causing the task to fail. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…EVEL When a preview doesn't specify an apiLevel, use the compileSdkVersion from detectEnvironment() (which reflects the project's actual compileSdk) instead of overriding it with a hardcoded MAX_API_LEVEL=36. The hardcoded value caused Renderer.configureBuildProperties to crash on Paparazzi 1.3.5 when its bundled layoutlib didn't support the SDK level. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
rbro112
approved these changes
Apr 13, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.


What
The generated
ComposablePreviewSnapshotTestnow compiles against both Paparazzi 1.x and 2.x. Previously it only worked with 2.x.Why
HtmlReportWriter(maxPercentDifference = tolerance)doesn't compile against Paparazzi 1.x because the 1.x constructor has nomaxPercentDifferenceparameter. In 2.x,maxPercentDifferenceis required (no default), so the no-argHtmlReportWriter()doesn't compile there. The generated code must differ per version.How
The plugin detects the Paparazzi major version from the declared
testImplementationdependencies at configuration time and passes it toGenerateSnapshotTestsTask. The task conditionally generatesHtmlReportWriter()for v1 orHtmlReportWriter(maxPercentDifference = tolerance)for v2+. Defaults to v2 when the version can't be determined.#skip-changelog
🤖 Generated with Claude Code