Skip to content

Gracefully handle panels that don't exist #2166

@tim-schilling

Description

@tim-schilling

It's more likely that a user will run into a 500 error where they request a panel id that doesn't exist now that we can persist the toolbar's store. I've run into this locally in my own testing a few times, but couldn't come up with a reproducible pattern.

Relevant code:

panel = toolbar.get_panel_by_id(request.GET["panel_id"])

Traceback

ERROR Internal Server Error: /__debug__/render_panel/
Traceback (most recent call last):
  File "/site-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
  File "/site-packages/django/core/handlers/base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/site-packages/sentry_sdk/integrations/django/views.py", line 94, in sentry_wrapped_callback
    return callback(request, *args, **kwargs)
  File "/site-packages/debug_toolbar/decorators.py", line 34, in inner
    return view(request, *args, **kwargs)
  File "/site-packages/debug_toolbar/decorators.py", line 46, in inner
    return view(request, *args, **kwargs)
  File "/site-packages/debug_toolbar/views.py", line 24, in render_panel
    panel = toolbar.get_panel_by_id(request.GET["panel_id"])
  File "/site-packages/debug_toolbar/toolbar.py", line 79, in get_panel_by_id
    return self._panels[panel_id]
           ~~~~~~~~~~~~^^^^^^^^^^
KeyError: 'ProfilingPanel'

I suspect we may want to add a custom exception here when an invalid panel is requested to make it easier for an API integration to be built on top of Toolbar.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy