TomBursch / kitchenowl

KitchenOwl is a self-hosted grocery list and recipe manager. The backend is made with Flask and the frontend with Flutter. Easily add items to your shopping list before you go shopping. You can also create recipes and add items based on what you want to cook.
https://kitchenowl.org/
GNU Affero General Public License v3.0
1.12k stars 62 forks source link

Bug: Empty cooktime causes recipe import to crash #419

Closed Bretterteig closed 3 months ago

Bretterteig commented 3 months ago

Is this urgent?

Yes

What parts are affected

Backend

What is the server version

v93

What is the client version

v92

What platform are you using

Web

What's the problem 🤔

Trying to import recipes from Hello Fresh does not work because the scraper returns null for cook_time.

Sample recipe:

Share your logs

ERROR:app.config:int() argument must be a string, a bytes-like object or a real number, not 'NoneType'
Traceback (most recent call last):
  File "/opt/venv/lib/python3.11/site-packages/flask/app.py", line 867, in full_dispatch_request
    rv = self.dispatch_request()
         ^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.11/site-packages/flask/app.py", line 852, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/venv/lib/python3.11/site-packages/flask_jwt_extended/view_decorators.py", line 170, in decorator
    return current_app.ensure_sync(fn)(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/kitchenowl/app/helpers/authorize_household.py", line 26, in decorator
    return func(*args, **kwargs)  # case server admin
           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/kitchenowl/app/helpers/validate_args.py", line 26, in func_wrapper
    return func(arguments, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/kitchenowl/app/controller/recipe/recipe_controller.py", line 208, in scrapeRecipe
    recipe.cook_time = int(scraper.cook_time())
                       ^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: int() argument must be a string, a bytes-like object or a real number, not 'NoneType'

Share your configuration

No response