bensi94 / Django-Requests-Tracker

The Django Requests Tracker is designed for local development, particularly for Rest API development. It provides various debugging information, such as SQL queries, headers, and status codes.
MIT License
37 stars 0 forks source link

Handle `KeyError` when request details is not existing anymore #13

Open AlTosterino opened 5 months ago

AlTosterino commented 5 months ago

Hey!

Currently, if you are on __request__tracker__ and restart the app, request tracker throws unhandled KeyError if you want to go into request details (which is not saved anywhere at this moment)

 File "/python3.11/site-packages/requests_tracker/views.py", line 118, in request_details
    context = request.request_collectors[UUID(str(request_id))].get_as_context()
              │       │                  │        └ 'bf1f647d-d71e-4ab9-a23a-b9268ead6e10'
              │       │                  └ <class 'uuid.UUID'>
              │       └ {}
              └ <ASGIRequest: GET '/__requests_tracker__/request-details/bf1f647d-d71e-4ab9-a23a-b9268ead6e10'>

KeyError: UUID('bf1f647d-d71e-4ab9-a23a-b9268ead6e10')
bensi94 commented 5 months ago

Thanks! I'll take a look.