Grocy-SwiftUI
Grocy-SwiftUI copied to clipboard
API decodingError due to layout issue
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):
-
Scan "Baked Beans"
-
See the an additional item. But don't want to scan and input everything again.
-
Goto "Bestand" & select "Baked Beans"
-
Select the "Bestandseintrag"
-
Change the amount from 1 to 2. Due to layout issues, I can not see the best_before_date. Save entry.
-
Get API error.
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))))
-
Log into webpage to see that the best_before_date was deleted.
-
Manually change the best_before_date
-
everything fine again.
This may help others with the same error. Maybe the layout of editing "Bestandseinträge" can be optimised
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.
- somehow, the layout is not working correctly (no idea why, looks normal on my devices)
- somehow, the app did a valid edit without a due date (this should be impossible, because of the internal checker)
- 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)
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:
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){
new: VStack(alignment: .trailing, spacing:5){
Thank you very much. Update v2.2.1 solved this issue.