pythondotorg icon indicating copy to clipboard operation
pythondotorg copied to clipboard

fix(sentry#6931306293): fix issue with url context resolver

Open JacobCoffee opened this issue 2 months ago • 0 comments

Description

  • When browsing somewhere nonexistent we crash and throw a Sentry error: https://www.python.org/search/?q=about&page=45 leads to: image which fails loading JS and the title bar is also funky: image

(InteractiveConsole)
>>> from django.test import RequestFactory
>>> 
>>> from pydotorg import context_processors
>>> 
>>>   factory = RequestFactory()
  File "<console>", line 1
    factory = RequestFactory()
IndentationError: unexpected indent
>>> factory = RequestFactory()
>>> request = factory.get('/this-does-not-exist/')
>>> result = context_processors.url_name(request)
>>> print(result)
{'URL_NAMESPACE': None, 'URL_NAME': None}
>>> request = factory.get('/about/')
>>> result = context_processors.url_name(request)
>>> 
>>> print(result)
{'URL_NAMESPACE': '', 'URL_NAME': 'about'}
>>> 

testing locally we get the right context: image

Closes

  • Fixes #2792

JacobCoffee avatar Oct 08 '25 16:10 JacobCoffee