cashapp / paparazzi

Render your Android screens without a physical device or emulator
https://cashapp.github.io/paparazzi/
Apache License 2.0
2.23k stars 211 forks source link

An unhelpful NullPointerException thrown if git LFS is misconfigured #1343

Closed Egorand closed 3 months ago

Egorand commented 3 months ago

Description A clear and concise description of what the bug is.

If git LFS was accidentally installed after a repo had been checked out, and thus the repo only contains pointer files, Paparazzi fails with a generic NullPointerException that's not easy to troubleshoot, e.g.:

java.lang.NullPointerException
        at app.cash.paparazzi.SnapshotVerifier$newFrameHandler$1.handle(SnapshotVerifier.kt:53)
        at app.cash.paparazzi.Paparazzi$takeSnapshots$1$3.invoke(Paparazzi.kt:343)
        at app.cash.paparazzi.Paparazzi$takeSnapshots$1$3.invoke(Paparazzi.kt:330)
        at app.cash.paparazzi.Paparazzi.withTime(Paparazzi.kt:378)
        at app.cash.paparazzi.Paparazzi.takeSnapshots(Paparazzi.kt:330)
        at app.cash.paparazzi.Paparazzi.snapshot(Paparazzi.kt:216)
        at app.cash.paparazzi.Paparazzi.snapshot$default(Paparazzi.kt:215)
        at com.squareup.cash.blockers.views.AmountBlockerViewTest.test(AmountBlockerViewTest.kt:66)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
        at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
        at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
        at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
        at app.cash.paparazzi.Paparazzi$apply$1.evaluate(Paparazzi.kt:147)
        at com.google.testing.junit.testparameterinjector.PluggableTestRunner$ContextMethodRule$1.evaluate(PluggableTestRunner.java:433)

This is somewhat of a duplicate of #1138, but with more precise repro steps.

Steps to Reproduce Provide a sample project, failing test, or steps to reproduce.

You either need a project that had been checked out before git LFS was installed, or you can revert one of the snapshot files to its pointer file format by running the following command:

git cat-file -e "HEAD:file-path" && git cat-file -p "HEAD:file-path" > "file-path"

Here, file-path has to be replaced with a path to the snapshot file, starting from the project directory, e.g.: "blockers/views/src/test/snapshots/images/com.squareup.cash.blockers.views_PasscodeViewTest_default[Dark,LARGE]_default.png", where "blockers" is a top-level project module.

Once the file has been modified, run the verifyPaparazziDebug task on the module that includes the file.

Expected behavior A clear and concise description of what you expected to happen.

The error message includes relevant details about the source of the issue, and possibly suggests troubleshooting steps.

Additional information:

Screenshots If applicable, add screenshots to help explain your problem.

N/A