patzly / grocy-android

ERP beyond your fridge, now on your phone – An awesome companion app for grocy
https://patrickzedler.com/grocy/
GNU General Public License v3.0
905 stars 85 forks source link

NullPointerException with missing quantity unit (v3.5.0) #833

Open heinrich-ulbricht opened 10 months ago

heinrich-ulbricht commented 10 months ago

The app seems to choke on missing quantity units. In my case the quantity of a product is just "6" with no "quantity unit stock" set.

This prevents the product from being consumed via bar code scan, as well as accessing the master data.

Grocy version 3.5.0

------ beginning of crash
01-28 12:59:10.939  6318  6318 E AndroidRuntime: FATAL EXCEPTION: main
01-28 12:59:10.939  6318  6318 E AndroidRuntime: Process: xyz.zedler.patrick.grocy, PID: 6318
01-28 12:59:10.939  6318  6318 E AndroidRuntime: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String xyz.zedler.patrick.grocy.model.QuantityUnit.getName()' on a null object reference
01-28 12:59:10.939  6318  6318 E AndroidRuntime:    at xyz.zedler.patrick.grocy.fragment.bottomSheetDialog.ProductOverviewBottomSheet.onViewCreated(ProductOverviewBottomSheet.java:572)
01-28 12:59:10.939  6318  6318 E AndroidRuntime:    at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:309)
01-28 12:59:10.939  6318  6318 E AndroidRuntime:    at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:151)
01-28 12:59:10.939  6318  6318 E AndroidRuntime:    at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1219)
01-28 12:59:10.939  6318  6318 E AndroidRuntime:    at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:92)
01-28 12:59:10.939  6318  6318 E AndroidRuntime:    at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:77)
01-28 12:59:10.939  6318  6318 E AndroidRuntime:    at androidx.fragment.app.FragmentManager$5.run(FragmentManager.java:4)
01-28 12:59:10.939  6318  6318 E AndroidRuntime:    at android.os.Handler.handleCallback(Handler.java:958)
01-28 12:59:10.939  6318  6318 E AndroidRuntime:    at android.os.Handler.dispatchMessage(Handler.java:99)
01-28 12:59:10.939  6318  6318 E AndroidRuntime:    at android.os.Looper.loopOnce(Looper.java:205)
01-28 12:59:10.939  6318  6318 E AndroidRuntime:    at android.os.Looper.loop(Looper.java:294)
01-28 12:59:10.939  6318  6318 E AndroidRuntime:    at android.app.ActivityThread.main(ActivityThread.java:8279)
01-28 12:59:10.939  6318  6318 E AndroidRuntime:    at java.lang.reflect.Method.invoke(Native Method)
01-28 12:59:10.939  6318  6318 E AndroidRuntime:    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
01-28 12:59:10.939  6318  6318 E AndroidRuntime:    at com.android.internal.os.ExecInit.main(ExecInit.java:49)
01-28 12:59:10.939  6318  6318 E AndroidRuntime:    at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
01-28 12:59:10.939  6318  6318 E AndroidRuntime:    at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:359)
heinrich-ulbricht commented 10 months ago

Not sure how I ended up in this situation. The browser UI seems to disallow this state and I also seem to be unable to rectify that. Note that this is for an existing product. image

I suspect the iOS app (by another indie developer) does strange things here. Wouldn't be the first time. Or botched server upgrade.

dominiczedler commented 10 months ago

Thanks! Yes there is always the chance that the API allows inputs which are not valid... The Grocy maintainer does his best to avoid that but it's always harder to implement UI errors and API errors together. I will see how this can be solved within our app.

dominiczedler commented 9 months ago

Mmh, do you have an idea how this should be handled by the app? Without the right quantity unit it is never good to proceed an action in the app anyway... Do you mean only the crash should be fixed and instead nothing of the QU can be displayed?

heinrich-ulbricht commented 9 months ago

It should not crash. But also no clue how to handle that. Maybe just a message "fix your database please" :)