Uploaded image for project: 'CPE Infrastructure'
  1. CPE Infrastructure
  2. CPE-2658

pagure returning 500s due to error in flask_oidc

XMLWordPrintable

    • False
    • None
    • False
    • Testable

      https://pagure.io/fedora-infrastructure/issue/12291

      1. Describe what you would like us to do:
        Fix a problem causing Pagure to return 500 Internal Server Error for logged-in users sometimes.

      This is affecting me and others in https://pagure.io/fedora-infrastructure/issue/12260 (but that issue is for something different, so I'm filing this). For me, I get a 500 any time I access pagure.io in Firefox, but it works in epiphany and when using curl. Looking on the server end, I found this in the logs:
      ```
      [Fri Nov 15 08:51:03.418011 2024] [wsgi:error] [pid 830440:tid 140652618757888] [remote 2001:569:70c8:c900:351f:a8d1:3133:6620:49058] 2024-11-15 08:51:03,417 [INFO] flask_oidc: Could not refresh token

      {'access_token': '[UUID-like string of 70 chars]', 'expires_at': 1731635156, 'expires_in': 3600, 'refresh_token': '[UUID-like string of 168 chars]', 'token_type': 'Bearer'}

      : invalid_grant: Something went wrong refreshing
      [Fri Nov 15 08:51:03.419763 2024] [wsgi:error] [pid 830440:tid 140652618757888] [remote 2001:569:70c8:c900:351f:a8d1:3133:6620:49058] mod_wsgi (pid=830440): Exception occurred processing WSGI script '/var/www/pagure.wsgi'.
      [Fri Nov 15 08:51:03.420899 2024] [wsgi:error] [pid 830440:tid 140652618757888] [remote 2001:569:70c8:c900:351f:a8d1:3133:6620:49058] Traceback (most recent call last):
      [Fri Nov 15 08:51:03.420950 2024] [wsgi:error] [pid 830440:tid 140652618757888] [remote 2001:569:70c8:c900:351f:a8d1:3133:6620:49058] File "/usr/lib/python3.6/site-packages/flask/app.py", line 1997, in _call_
      [Fri Nov 15 08:51:03.420957 2024] [wsgi:error] [pid 830440:tid 140652618757888] [remote 2001:569:70c8:c900:351f:a8d1:3133:6620:49058] return self.wsgi_app(environ, start_response)
      [Fri Nov 15 08:51:03.420966 2024] [wsgi:error] [pid 830440:tid 140652618757888] [remote 2001:569:70c8:c900:351f:a8d1:3133:6620:49058] File "/usr/lib/python3.6/site-packages/whitenoise/base.py", line 85, in _call_
      [Fri Nov 15 08:51:03.420971 2024] [wsgi:error] [pid 830440:tid 140652618757888] [remote 2001:569:70c8:c900:351f:a8d1:3133:6620:49058] return self.application(environ, start_response)
      [Fri Nov 15 08:51:03.420980 2024] [wsgi:error] [pid 830440:tid 140652618757888] [remote 2001:569:70c8:c900:351f:a8d1:3133:6620:49058] File "/usr/lib/python3.6/site-packages/pagure/proxy.py", line 74, in _call_
      [Fri Nov 15 08:51:03.420985 2024] [wsgi:error] [pid 830440:tid 140652618757888] [remote 2001:569:70c8:c900:351f:a8d1:3133:6620:49058] return self.app(environ, start_response)
      [Fri Nov 15 08:51:03.420993 2024] [wsgi:error] [pid 830440:tid 140652618757888] [remote 2001:569:70c8:c900:351f:a8d1:3133:6620:49058] File "/usr/lib/python3.6/site-packages/flask/app.py", line 1993, in wsgi_app
      [Fri Nov 15 08:51:03.420998 2024] [wsgi:error] [pid 830440:tid 140652618757888] [remote 2001:569:70c8:c900:351f:a8d1:3133:6620:49058] ctx.auto_pop(error)
      [Fri Nov 15 08:51:03.421007 2024] [wsgi:error] [pid 830440:tid 140652618757888] [remote 2001:569:70c8:c900:351f:a8d1:3133:6620:49058] File "/usr/lib/python3.6/site-packages/flask/ctx.py", line 387, in auto_pop
      [Fri Nov 15 08:51:03.421012 2024] [wsgi:error] [pid 830440:tid 140652618757888] [remote 2001:569:70c8:c900:351f:a8d1:3133:6620:49058] self.pop(exc)
      [Fri Nov 15 08:51:03.421020 2024] [wsgi:error] [pid 830440:tid 140652618757888] [remote 2001:569:70c8:c900:351f:a8d1:3133:6620:49058] File "/usr/lib/python3.6/site-packages/flask/ctx.py", line 353, in pop
      [Fri Nov 15 08:51:03.421025 2024] [wsgi:error] [pid 830440:tid 140652618757888] [remote 2001:569:70c8:c900:351f:a8d1:3133:6620:49058] self.app.do_teardown_request(exc)
      [Fri Nov 15 08:51:03.421033 2024] [wsgi:error] [pid 830440:tid 140652618757888] [remote 2001:569:70c8:c900:351f:a8d1:3133:6620:49058] File "/usr/lib/python3.6/site-packages/flask/app.py", line 1879, in do_teardown_request
      [Fri Nov 15 08:51:03.421039 2024] [wsgi:error] [pid 830440:tid 140652618757888] [remote 2001:569:70c8:c900:351f:a8d1:3133:6620:49058] func(exc)
      [Fri Nov 15 08:51:03.421047 2024] [wsgi:error] [pid 830440:tid 140652618757888] [remote 2001:569:70c8:c900:351f:a8d1:3133:6620:49058] File "/usr/lib/python3.6/site-packages/pagure/flask_app.py", line 536, in end_request
      [Fri Nov 15 08:51:03.421053 2024] [wsgi:error] [pid 830440:tid 140652618757888] [remote 2001:569:70c8:c900:351f:a8d1:3133:6620:49058] flask.g.session.remove()
      [Fri Nov 15 08:51:03.421069 2024] [wsgi:error] [pid 830440:tid 140652618757888] [remote 2001:569:70c8:c900:351f:a8d1:3133:6620:49058] File "/usr/lib/python3.6/site-packages/werkzeug/local.py", line 347, in _getattr_
      [Fri Nov 15 08:51:03.421074 2024] [wsgi:error] [pid 830440:tid 140652618757888] [remote 2001:569:70c8:c900:351f:a8d1:3133:6620:49058] return getattr(self._get_current_object(), name)
      [Fri Nov 15 08:51:03.421095 2024] [wsgi:error] [pid 830440:tid 140652618757888] [remote 2001:569:70c8:c900:351f:a8d1:3133:6620:49058] AttributeError: '_AppCtxGlobals' object has no attribute 'session'
      ```
      I have edited the actual tokens for obvious reasons, you can see the real values in `/var/log/httpd/error_log` on pagure02 if you have access.

      1. When do you need this to be done by? (YYYY/MM/DD)
        ASAP.

              Unassigned Unassigned
              rh-ee-mkonecny Michal Konecny
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: