osnsyc / GrocyCompanionCN

条形码商品识别
105 stars 11 forks source link

使用特定产品创建条目后继续添加该产品出现500错误 #8

Open hahaha3542 opened 8 months ago

hahaha3542 commented 8 months ago

在我进行批量物品导入测试时发现有一个产品创建条目正常,但是累加入库时出现了无故500报错,不清楚是否为获取到的GDSInfo内容触发了某个隐形BUG

产品ISBN:6907992513560

错误日志如下

ERROR:app:Exception on /add [POST] Traceback (most recent call last): File "./app.py", line 136, in add grocy.product_by_barcode(barcode) File "/usr/local/lib/python3.8/site-packages/pygrocy/grocy.py", line 102, in product_by_barcode resp = self._api_client.get_product_by_barcode(barcode) File "/usr/local/lib/python3.8/site-packages/pygrocy/grocy_api_client.py", line 435, in get_product_by_barcode parsed_json = self._do_get_request(url) File "/usr/local/lib/python3.8/site-packages/pygrocy/grocy_api_client.py", line 358, in _do_get_request raise GrocyError(resp) pygrocy.errors.grocy_error.GrocyError: <Response [400]>

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 2073, in wsgi_app response = self.full_dispatch_request() File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1518, in full_dispatch_request rv = self.handle_user_exception(e) File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1516, in full_dispatch_request rv = self.dispatch_request() File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1502, in dispatch_request return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args) File "./app.py", line 147, in add if add_product(good, client): File "./app.py", line 54, in add_product response_grocy = grocy.add_generic(EntityType.PRODUCTS, data_grocy) File "/usr/local/lib/python3.8/site-packages/pygrocy/grocy.py", line 368, in add_generic return self._api_client.add_generic(entity_type.value, data) File "/usr/local/lib/python3.8/site-packages/pygrocy/grocy_api_client.py", line 783, in add_generic return self._do_post_request(f"objects/{entity_type}", data) File "/usr/local/lib/python3.8/site-packages/pygrocy/grocy_api_client.py", line 375, in _do_post_request raise GrocyError(resp) pygrocy.errors.grocy_error.GrocyError: <Response [400]> INFO:werkzeug:10.10.10.200 - - [06/Apr/2024 21:16:57] "POST /add HTTP/1.1" 500 -

GDSInfo信息:

{"keyword": "安慕希", "branch_code": "1505", "gtin": "06907992513560", "specification": "200克", "is_private": false, "firm_name": "内蒙古伊利实业集团股份有限公司", "brandcn": "安慕希", "picture_filename": "https://oss.gds.org.cn/userfile1/uploadb/gra/sj220526144003168897/06907992513560/06907992513560.1.jpg", "description": "安慕希黄桃+燕麦希腊风味酸奶", "logout_flag": "0", "have_ms_product": 0, "base_create_time": "2017-01-17T11:45:53.69", "branch_name": "内蒙古分中心", "base_source": "WWW", "gpc": "10000279", "gpcname": "酸奶(耐储存)", "saledate": null, "saledateyear": null, "base_last_updated": "2024-03-19T10:41:06.677", "base_user_id": "伊利", "code": "6907992", "levels": null, "levels_source": null, "valid_date": "2025-09-20T00:00:00", "logout_date": null, "gtinstatus": 1}

sliveysun commented 5 months ago

得改下代码,把这个错误的详细信息打印出来:pygrocy.errors.grocy_error.GrocyError: <Response [400]>