Bug: Barcodes are returned as integers in API call
See original GitHub issueBy running GET api/objects/product_barcodes
, the barcode values are returned as int. In previous versions it was a string however, which is a breaking change. The output will be a string, if any non numeric characters are included in the barcode, which is unpredictable behaviour for an API call.
This also means that barcodes with leading zeros will be incorrectly transmitted by the API call: The barcode 000123
would be correctly displayed in the Grocy menu, but the API call would return 123
.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:6 (5 by maintainers)
Top Results From Across the Web
integer error for Read10X #4030 - satijalab/seurat - GitHub
I want to load a large-scale single cell data using Read10X. But there is an error message as follows: Error in scan(file, nmax...
Read more >Barcode API Calls - PCR-360 - Confluence
To configure the number of Pages/Results returned by the API (this is most useful for the SQL Endpoint), you can send these as...
Read more >API: Return Input From Keyboard Wedge Device
Receive data from keyboard wedge devices, such as keyboards & scanners. These types of peripherals can connect via Bluetooth or USB.
Read more >food.find_id_for_barcode - REST API - FatSecret Platform
Returns the food_id matching the barcode specified. Barcodes must be specified as GTIN-13 numbers - a 13-digit number filled in with zeros for...
Read more >ShipStation API
ShipStation's support team is not able to help you design or build an API integration, but we can certainly help test API calls...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve tried some approaches to solve this (for example by having a list of numeric field names + generically iterating over the API response and setting the type based on that) without success so far.
So definitely was not a good idea to do this that way and probably needs to be undone for now. Shit happens.
That everything retrieved from the database is a string is neither SQLite’s fault, nor one of the ORM used (LessQL) - it’s PDO.
And it seems that just that was now finally implemented (15 year old feature request) for PHP 8.1 (haven’t tested it so far): https://bugs.php.net/bug.php?id=38334 https://github.com/php/php-src/commit/438b025a28cda2935613af412fc13702883dd3a2
Off-topic:
What me brought to doing this was just the moaning of someone that grocy is so fkn bad in any kind, and one of the "arguments" was that a not strictly typed API is the worst thing you could have. JSON_NUMERIC_CHECK looked at a first glance to exactly "fix" that. I have personally absolutely no problem (for this project) about being lazy about data types, it's sometimes even fun. So I need to learn to ignore those type of people better (unfortunately this seem to get more the bigger the community around grocy gets, but that's the world I think), since that even reduces my desire and fun to work on this project at all lately - so sorry for that.Maybe undo this step and perform numeric conversions for each wanted key in a response would be the best way to solve the issue?
I can’t find any workaround which would work with the
JSON_NUMERIC_CHECK
together in this case, because you use the json_encode in a very general method (I think it is ApiResponse).And below this comment and in the php user contributed notes people recommend to not use the way to convert all things which look like numbers to numbers.
But I know that doing the conversion manually for every number (without barcodes) would be hard work…