You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 23, 2024. It is now read-only.
When requesting a product for which the product group is not set, an exception is raised by pygrocy.
Following example from the demo instance:
from pygrocy import Grocy
grocy = Grocy('https://demo.grocy.info','',port=443)
product = grocy.product(27)
This raises the following exception:
Traceback (most recent call last):
File "/mnt/d/Code/grocy-openfoodfacts/test.py", line 5, in <module>
product = grocy.product(27)
File "/home/andreheuer/.local/lib/python3.8/site-packages/pygrocy/grocy.py", line 96, in product
resp = self._api_client.get_product(product_id)
File "/home/andreheuer/.local/lib/python3.8/site-packages/pygrocy/grocy_api_client.py", line 349, in get_product
return ProductDetailsResponse(**parsed_json)
File "pydantic/main.py", line 406, in pydantic.main.BaseModel.__init__
pydantic.error_wrappers.ValidationError: 1 validation error for ProductDetailsResponse
product -> product_group_id
value is not a valid integer (type=type_error.integer)
The text was updated successfully, but these errors were encountered:
Hi,
I'd do a pull request for this but my Python isn't great and I don't know if this is the preferred way of fixing this.
I fixed the product_group_id problem by importing validator from pydantic and adding the second code block to the end of the ProductData definition. Not sure why the definition doesn't work that already exists but as I said, my Python is terrible.
from pydantic import BaseModel, Field, validator
validator('product_group_id', pre=True)
def blank_string(value, field):
if value == "":
return None
return value
When requesting a product for which the product group is not set, an exception is raised by pygrocy.
Following example from the demo instance:
This raises the following exception:
The text was updated successfully, but these errors were encountered: