alexbates / Tamari

A fully-featured recipe manager web application built using Python and the Flask Framework.
https://tamariapp.com
GNU General Public License v3.0
68 stars 1 forks source link

Error when saving recipe #4

Closed ericlay closed 4 months ago

ericlay commented 4 months ago

Thanks for this! It looks like a great solution without being over done. Unfortunately, when I am navigating and attempting to save recipes I have found in the Explore tab, I get this error message:

 [2024-06-06 21:27:13,653] ERROR in app: Exception on /explore/recipe/air-fryer/32 [POST]
tamari  | Traceback (most recent call last):
tamari  |   File "/usr/local/lib/python3.12/site-packages/flask/app.py", line 2190, in wsgi_app
tamari  |     response = self.full_dispatch_request()
tamari  |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tamari  |   File "/usr/local/lib/python3.12/site-packages/flask/app.py", line 1486, in full_dispatch_request
tamari  |     rv = self.handle_user_exception(e)
tamari  |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tamari  |   File "/usr/local/lib/python3.12/site-packages/flask/app.py", line 1484, in full_dispatch_request
tamari  |     rv = self.dispatch_request()
tamari  |          ^^^^^^^^^^^^^^^^^^^^^^^
tamari  |   File "/usr/local/lib/python3.12/site-packages/flask/app.py", line 1469, in dispatch_request
tamari  |     return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
tamari  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tamari  |   File "/usr/local/lib/python3.12/site-packages/flask_login/utils.py", line 290, in decorated_view
tamari  |     return current_app.ensure_sync(func)(*args, **kwargs)
tamari  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tamari  |   File "/usr/local/lib/python3.12/site-packages/flask_limiter/extension.py", line 1303, in __inner
tamari  |     return cast(R, flask.current_app.ensure_sync(obj)(*a, **k))
tamari  |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tamari  |   File "/app/explore/routes.py", line 1316, in exploreRecipeDetail
tamari  |     hsize = int((float(img.size[1])*float(wpercent)))
tamari  |                                           ^^^^^^^^
tamari  | UnboundLocalError: cannot access local variable 'wpercent' where it is not associated with a value

I am using docker compose:

services:
    tamari:
        image: alexbates/tamari:0.6
        container_name: tamari
        restart: always
        volumes:
            - tamariappdata:/app/appdata
        networks:
          - reverseproxy-network
        # ports:
            # - 4888:4888
volumes:
    tamariappdata:
        external: true
        name: tamariappdata

networks:
  reverseproxy-network:
    external: true

and for good measure the reverse proxy (caddy) config:

recipes.example.com {
    log {
        output file /var/log/caddy/recipes-access.log {
            roll_size 250Mib
            roll_keep 5
            roll_keep_for 720h
        }
        format json {
            time_format wall
        }
        level INFO
    }
    encode gzip zstd
    import localSubnets
    reverse_proxy @localSubnets tamari:4888 {
        header_down Content-Security-Policy "upgrade-insecure-requests"
                header_up Host {host}
        header_up X-Forwarded-For {remote}
        header_up X-Real-IP {remote}
        header_up X-Forward-Proto {scheme}
    }
}
alexbates commented 4 months ago

Thanks for reporting this! This was a major bug impacting all recipes with portrait photos. Fixed and pushed new Docker images.

I just used web automation software to find and fix two other errors that occurred when saving certain recipes. Now, very few recipes should fail to save. Still, somewhere between 5% and 10% of recipes give "failed to parse" error when attempting to view. I will be working to improve parsing code and remove non-recipe articles in the coming weeks.

ericlay commented 4 months ago

Thanks for the quick fix! Can confirm recipes are saved as expected after updating the container.