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

KeyError: "alerts" in nav_subtitle if alerts stats not present #1951

Closed
danjac opened this issue Jul 5, 2024 · 2 comments
Closed

KeyError: "alerts" in nav_subtitle if alerts stats not present #1951

danjac opened this issue Jul 5, 2024 · 2 comments

Comments

@danjac
Copy link
Contributor

danjac commented Jul 5, 2024

If the stats for the alert panel are absent (e.g. a StreamingHttpResponse) a KeyError is raised:

  File "/my-project/.venv/lib/python3.12/site-packages/django/template/base.py", line 710, in resolve
    obj = self.var.resolve(context)
          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/my-project/.venv/lib/python3.12/site-packages/django/template/base.py", line 842, in resolve
    value = self._resolve_lookup(context)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/my-project/.venv/lib/python3.12/site-packages/django/template/base.py", line 885, in _resolve_lookup
    current = getattr(current, bit)
              ^^^^^^^^^^^^^^^^^^^^^
  File "/my-project/.venv/lib/python3.12/site-packages/debug_toolbar/panels/alerts.py", line 86, in nav_subtitle
    alerts = self.get_stats()["alerts"]
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
KeyError: 'alerts'
``
matthiask added a commit to matthiask/django-debug-toolbar that referenced this issue Jul 5, 2024
@matthiask
Copy link
Member

Thanks for the report! #1953 hopefully fixes this.

@danjac
Copy link
Contributor Author

danjac commented Jul 5, 2024

Really fast turnaround, thank you!

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