takahirom / roborazzi

Make JVM Android integration test visible 🤖📸
https://takahirom.github.io/roborazzi/
Apache License 2.0
739 stars 35 forks source link

git lfs - Potential for better error messaging? #503

Open trevjonez opened 1 month ago

trevjonez commented 1 month ago

While working through migrating some jobs from circle CI over to GHA I hit an error in the test run due to git-lfs not being setup correctly on our self hosted runners.

Stack of the error looks like this:

java.lang.NullPointerException: read(...) must not be null
at com.github.takahirom.roborazzi.AwtRoboCanvas$Companion.load(AwtRoboCanvas.kt:312)
at com.github.takahirom.roborazzi.RoborazziKt.processOutputImageAndReportWithDefaults$lambda$21(Roborazzi.kt:647)
at com.github.takahirom.roborazzi.ProcessOutputImageAndReportKt.processOutputImageAndReport(processOutputImageAndReport.kt:79)
at com.github.takahirom.roborazzi.RoborazziKt.processOutputImageAndReportWithDefaults(Roborazzi.kt:634)
at com.github.takahirom.roborazzi.RoborazziKt$captureScreenRoboImage$3.invoke(Roborazzi.kt:158)
at com.github.takahirom.roborazzi.RoborazziKt$captureScreenRoboImage$3.invoke(Roborazzi.kt:151)
at com.github.takahirom.roborazzi.RoborazziKt.capture(Roborazzi.kt:614)
at com.github.takahirom.roborazzi.RoborazziKt.captureScreenRoboImage(Roborazzi.kt:151) 
at com.github.takahirom.roborazzi.RoborazziKt.captureScreenRoboImage(Roborazzi.kt:123)
at com.github.takahirom.roborazzi.RoborazziKt.captureScreenRoboImage$default(Roborazzi.kt:118)

https://github.com/takahirom/roborazzi/blob/828760f94d77be152e6ed12b68263d5bf0cc6463/roborazzi-painter/src/commonJvmMain/kotlin/com/github/takahirom/roborazzi/AwtRoboCanvas.kt#L312

that line could be augmented pretty easily to provide some extra information something like this?

val loadedImage: BufferedImage = requireNotNull(ImageIO.read(file)) {
  "Failed to read file: ${file.path}. If you are using git-lfs ensure it has been setup correctly on this host."
}
takahirom commented 1 month ago

@trevjonez Thanks. I think not everyone uses Git LFS, and there could be other reasons. So how about making it like this? "Failed to read the file at ${file.path} as an image. Please check the file or the environment. This issue could occur if you are using Git LFS and it is not set up correctly."