felixschndr / mealie-bring-api

A simple webserver that allows ingredients sent by mealie to be added to a bring shopping list
11 stars 2 forks source link

Exception on /POST - mealie version 2.0.0 #9

Closed m-a-johnson closed 4 weeks ago

m-a-johnson commented 4 weeks ago

Not sure if this is because I am using Mealie version 2.0.0 (which seems to break a lot of API related stuff), but I get an error when sending a recipe to mealie-bring-api. I set log level to "DEBUG" and redacted some info.

[2024-10-28 15:20:40,796] [BringHandler] [DEBUG] [Bring credentials and list name are set]
[2024-10-28 15:20:40,796] [BringHandler] [INFO] [The variable IGNORED_INGREDIENTS is not set. All ingredients will be added. Consider adding something like "Salt,Pepper"]
[2024-10-28 15:20:40,797] [BringHandler] [INFO] [Attempting the login into Bring]
[2024-10-28 15:20:41,422] [python_bring_api.bring] [DEBUG] [Response from https://api.getbring.com/rest/v2/bringauth: 200]
[2024-10-28 15:20:41,424] [BringHandler] [INFO] [Login successful]
[2024-10-28 15:20:41,722] [python_bring_api.bring] [DEBUG] [Response from https://api.getbring.com/rest/v2/bringusers/[REDACTED]/lists: 200]
[2024-10-28 15:20:41,723] [BringHandler] [INFO] [Found the list with the name "Weekly Groceries" (UUID: [REDACTED])]
[2024-10-28 15:20:41,723] [Main] [INFO] [Listening on 0.0.0.0:8742]
 * Serving Flask app 'main'
 * Debug mode: off
[2024-10-28 15:21:41,462] [main] [ERROR] [Exception on / [POST]]
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1473, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 882, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 880, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 865, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]
  File "/app/main.py", line 22, in webhook_handler
    logger.log.info(f'Received recipe "{data["name"]}" from "{request.remote_addr}"')
KeyError: 'name'
felixschndr commented 4 weeks ago

Thanks for pointing it out! I installed mealie 2.0.0 some days ago and haven't used the integration yet. I will take a closer look at this and come back to you

felixschndr commented 4 weeks ago

@m-a-johnson I fixed the problem. A lot of attribute names changed in the new version.

After pulling the image with docker pull ghcr.io/felixschndr/mealie-bring-api:main you should be good to go again :)

m-a-johnson commented 4 weeks ago

Thank you! That is working. Much appreciated.