Skip to content

Opening tag page forces request to GitHub #1053

@jchristgit

Description

@jchristgit

Local testing with httrack for broken links results in these errors being printed to the console:

Traceback (most recent call last):
  File "/home/jc/.cache/pypoetry/virtualenvs/site-_f36zgtP-py3.11/lib/python3.11/site-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
               ^^^^^^^^^^^^^^^^^^^^^
  File "/home/jc/.cache/pypoetry/virtualenvs/site-_f36zgtP-py3.11/lib/python3.11/site-packages/django/core/handlers/base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jc/.cache/pypoetry/virtualenvs/site-_f36zgtP-py3.11/lib/python3.11/site-packages/sentry_sdk/integrations/django/views.py", line 84, in sentry_wrapped_callback
    return callback(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jc/.cache/pypoetry/virtualenvs/site-_f36zgtP-py3.11/lib/python3.11/site-packages/django/views/generic/base.py", line 98, in view
    self.setup(request, *args, **kwargs)
  File "/home/jc/workspace/pydis-site/pydis_site/apps/content/views/tags.py", line 32, in setup
    self.tag = utils.get_tag(kwargs.get("location"))
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jc/workspace/pydis-site/pydis_site/apps/content/utils.py", line 245, in get_tag
    set_tag_commit(tag)
  File "/home/jc/workspace/pydis-site/pydis_site/apps/content/utils.py", line 148, in set_tag_commit
    data.raise_for_status()
  File "/home/jc/.cache/pypoetry/virtualenvs/site-_f36zgtP-py3.11/lib/python3.11/site-packages/httpx/_models.py", line 749, in raise_for_status
    raise HTTPStatusError(message, request=request, response=self)
httpx.HTTPStatusError: Client error '403 rate limit exceeded' for url 'https://api.github.com/repos/python-discord/bot/commits?path=/bot/resources/tags/strip-gotcha.md'
For more information check: https://httpstatuses.com/403
"GET /pages/tags/strip-gotcha/ HTTP/1.1" 500 95740

One for each accessed tag. Suboptimal.

I think it would be better if this would soft-fail, or better, if it wouldn't run a separate request for each tag. Alternatively as a quick fix we could add the "set GitHub token" as a precondition.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions