Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

500 error for /backup and /restore #10

Closed
MattDahEpic opened this issue Jun 24, 2023 · 2 comments
Closed

500 error for /backup and /restore #10

MattDahEpic opened this issue Jun 24, 2023 · 2 comments

Comments

@MattDahEpic
Copy link
Contributor

Using the navbar buttons or manually navigating to /backup or /restore results in a 500 error with the following message logged in the web server logs:

Jun 23 20:01:25 adsb flask[858]:   File "/usr/local/lib/python3.9/dist-packages/jinja2/environment.py", line 936, in handle_exception
Jun 23 20:01:25 adsb flask[858]:     raise rewrite_traceback_stack(source=source)
Jun 23 20:01:25 adsb flask[858]:   File "/usr/local/share/adsb-pi-setup/templates/backup.html", line 2, in top-level template code
Jun 23 20:01:25 adsb flask[858]:     {% set active_page = "backup" %}
Jun 23 20:01:25 adsb flask[858]:   File "/usr/local/share/adsb-pi-setup/templates/base.html", line 34, in top-level template code
Jun 23 20:01:25 adsb flask[858]:     style="display: {% if env_values['BASE_CONFIG'] == "1" or
Jun 23 20:01:25 adsb flask[858]:   File "/usr/local/lib/python3.9/dist-packages/jinja2/environment.py", line 466, in getitem
Jun 23 20:01:25 adsb flask[858]:     return obj[argument]
Jun 23 20:01:25 adsb flask[858]: jinja2.exceptions.UndefinedError: 'env_values' is undefined
Jun 23 20:01:25 adsb flask[858]: 127.0.0.1 - - [24/Jun/2023 04:01:25] "GET /backup HTTP/1.1" 500 -

I'm not too familiar with Flask but it appears to be an error with showing/hiding the navbar in the base template. Changing the order of the conditions in the if on the affected lines to force a short-circuit in the condition on the affected pages does not resolve the issue.

Occurs on v0.9.2 and testbuild-g-f6bd5de6.

@dirkhh
Copy link
Owner

dirkhh commented Jun 24, 2023

Whenever a page is rendered, we need to pass in the env_vars so that the base template works.

I didn't think there was any caller left that didn't do that, but it looks like you found one.
I can't quite tell where the render_template() is called from. I'll poke at this...

@dirkhh
Copy link
Owner

dirkhh commented Jun 24, 2023

Crud.
I clearly didn't test backup and restore after the last edit of the base template.
All that is needed is to pass env_values=ENV_VALUES.envs to the render_template() calls for backup and restore.
Again, another great find!

@dirkhh dirkhh closed this as completed in 19271f3 Jun 24, 2023
dirkhh added a commit that referenced this issue Jun 24, 2023
Ensure backup and restore routes have env_values (resolves #10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants