Uploaded image for project: 'Automation Hub'
  1. Automation Hub
  2. AAH-2733

server error 500 on galaxy.ansible.com/api/v1/namespaces/ with enabled Browsable API

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Undefined Undefined
    • None
    • Unspecified
    • Backend
    • None

      server error is reproducible when user is logged in (https://galaxy.ansible.com/ui/) and then visits https://galaxy.ansible.com/api/v1/namespaces 

      2023-10-02 15:19:35,750 ERROR django.request: Internal Server Error: /api/v1/namespaces/
      Traceback (most recent call last):
        File "/venv/lib64/python3.11/site-packages/django/core/handlers/exception.py", line 55, in inner
          response = get_response(request)
                     ^^^^^^^^^^^^^^^^^^^^^
        File "/venv/lib64/python3.11/site-packages/django/core/handlers/base.py", line 220, in _get_response
          response = response.render()
                     ^^^^^^^^^^^^^^^^^
        File "/venv/lib64/python3.11/site-packages/django/template/response.py", line 114, in render
          self.content = self.rendered_content
                         ^^^^^^^^^^^^^^^^^^^^^
        File "/venv/lib64/python3.11/site-packages/rest_framework/response.py", line 70, in rendered_content
          ret = renderer.render(self.data, accepted_media_type, context)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/venv/lib64/python3.11/site-packages/rest_framework/renderers.py", line 723, in render
          context = self.get_context(data, accepted_media_type, renderer_context)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/venv/lib64/python3.11/site-packages/rest_framework/renderers.py", line 654, in get_context
          raw_data_post_form = self.get_raw_data_form(data, view, 'POST', request)
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/venv/lib64/python3.11/site-packages/rest_framework/renderers.py", line 540, in get_raw_data_form
          if not self.show_form_for_method(view, method, request, instance):
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/venv/lib64/python3.11/site-packages/rest_framework/renderers.py", line 430, in show_form_for_method
          view.check_permissions(request)
        File "/venv/lib64/python3.11/site-packages/rest_framework/views.py", line 332, in check_permissions
          if not permission.has_permission(request, self):
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/venv/lib64/python3.11/site-packages/rest_access_policy/access_policy.py", line 69, in has_permission
          allowed = self._evaluate_statements(statements, request, view, action)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/venv/lib64/python3.11/site-packages/rest_access_policy/access_policy.py", line 113, in _evaluate_statements
          matched = self._get_statements_matching_conditions(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/venv/lib64/python3.11/site-packages/rest_access_policy/access_policy.py", line 262, in _get_statements_matching_conditions
          passed = self._check_condition(condition, request, view, action)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/venv/lib64/python3.11/site-packages/rest_access_policy/access_policy.py", line 288, in _check_condition
          result = method(request, view, action)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/app/galaxy_ng/app/access_control/access_policy.py", line 784, in is_namespace_owner
          ns_id = kwargs['pk']
                  ~~~~~~^^^^^^
      KeyError: 'pk'
      2023-10-02 15:19:35,752 INFO gunicorn.access: 10.128.41.115 - - [02/Oct/2023:15:19:35 +0000] "GET /api/v1/namespaces/ HTTP/1.0" 500 145 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Safari/605.1.15" 

      endpoint works correctly in anonymous window or different browser

              jjerabek@redhat.com Jiri Jerabek
              jjerabek@redhat.com Jiri Jerabek
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: