Grocy-SwiftUI icon indicating copy to clipboard operation
Grocy-SwiftUI copied to clipboard

API decodingError due to layout issue

Open Tuphal opened this issue 3 years ago • 4 comments

I had the same problem as issue #55 I was able to reproduce it and found the the issue in the layout/behaviour.

Reproducing steps (sorry I don't have the english translation here):

  1. Scan "Baked Beans"

  2. See the an additional item. But don't want to scan and input everything again.

  3. Goto "Bestand" & select "Baked Beans" grafik

  4. Select the "Bestandseintrag" grafik

  5. Change the amount from 1 to 2. Due to layout issues, I can not see the best_before_date. Save entry. grafik

  6. Get API error. grafik Errorlog:

02.02.2022, 15:53:56: Get stock failed. decodingError(error: Grocy_Mobile.APIError.decodingError(error: Swift.DecodingError.valueNotFound(Swift.String, Swift.DecodingError.Context(codingPath: [_JSONKey(stringValue: "Index 35", intValue: 35), CodingKeys(stringValue: "best_before_date", intValue: nil)], debugDescription: "Expected String value but found null instead.", underlyingError: nil))))
02.02.2022, 15:53:56: Data request failed for Stock. Message: decodingError(error: Grocy_Mobile.APIError.decodingError(error: Swift.DecodingError.valueNotFound(Swift.String, Swift.DecodingError.Context(codingPath: [_JSONKey(stringValue: "Index 35", intValue: 35), CodingKeys(stringValue: "best_before_date", intValue: nil)], debugDescription: "Expected String value but found null instead.", underlyingError: nil))))
02.02.2022, 15:53:57: Get stock failed. decodingError(error: Grocy_Mobile.APIError.decodingError(error: Swift.DecodingError.valueNotFound(Swift.String, Swift.DecodingError.Context(codingPath: [_JSONKey(stringValue: "Index 35", intValue: 35), CodingKeys(stringValue: "best_before_date", intValue: nil)], debugDescription: "Expected String value but found null instead.", underlyingError: nil))))
02.02.2022, 15:53:57: Data request failed for Stock. Message: decodingError(error: Grocy_Mobile.APIError.decodingError(error: Swift.DecodingError.valueNotFound(Swift.String, Swift.DecodingError.Context(codingPath: [_JSONKey(stringValue: "Index 35", intValue: 35), CodingKeys(stringValue: "best_before_date", intValue: nil)], debugDescription: "Expected String value but found null instead.", underlyingError: nil))))
  1. Log into webpage to see that the best_before_date was deleted. grafik

  2. Manually change the best_before_date

  3. everything fine again.

This may help others with the same error. Maybe the layout of editing "Bestandseinträge" can be optimised

Tuphal avatar Feb 02 '22 19:02 Tuphal

No worries, German is a first class language in the app (it gets developed with English in parallel).

Well, I can't reproduce this problem. It seems like the combination of three different problems.

  1. somehow, the layout is not working correctly (no idea why, looks normal on my devices)
  2. somehow, the app did a valid edit without a due date (this should be impossible, because of the internal checker)
  3. the missing due date throws the shown error. This problem was actually fixed with the 2.2.0 update

Try to update your app + server. If this doesn't help, check if you can reproduce this problem on the official demo server (demo.grocy.info)

supergeorg avatar Feb 04 '22 17:02 supergeorg

I tested with the demo-server and got the same layout shown. I could not test iOS 14 because the app can only be downloaded in iOS15. All devices are on the newest update 15.3.

I suspected the display size (i have a iPhone 11 6,1") therefore I tested an iPad (1st Gen iPad Pro 12,9") and older iPhone (iPhone 6s 4,7″) with the demo-server but get the same layout issue: grafik grafik grafik

Tuphal avatar Feb 10 '22 08:02 Tuphal

first: I have no idea what I'm doing. I installed Xcode the first time and took a look at the project. Also I have no idea how to submit this solution via GitHub. Sorry.

Please add to the VStack a spacing: https://github.com/supergeorg/Grocy-SwiftUI/blob/1381ebfcf67d869e6546edb61e4d4997f3e011da/Shared/Views/Stock/StockEntryFormView.swift#L92

old: VStack(alignment: .trailing){ old

new: VStack(alignment: .trailing, spacing:5){ new

Tuphal avatar Feb 10 '22 10:02 Tuphal

Thank you very much. Update v2.2.1 solved this issue.

Tuphal avatar Feb 14 '22 07:02 Tuphal