Skip to content

500 Server Error when listing user roles #6330

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
grzleadams opened this issue Mar 5, 2025 · 8 comments · May be fixed by #6334
Open

500 Server Error when listing user roles #6330

grzleadams opened this issue Mar 5, 2025 · 8 comments · May be fixed by #6334
Labels

Comments

@grzleadams
Copy link

Version
Deployed in Kubernetes via Pulp Operator/Helm chart. Image is pulp-minimal:3.63.11.

      "versions": {                                                                                   
        "deb": "3.5.1",                                                                               
        "rpm": "3.27.2",                                                                              
        "core": "3.63.11",                                                                            
        "file": "3.63.11",                                                                            
        "maven": "0.8.3",                                                                             
        "ostree": "2.4.6",                                                                            
        "python": "3.13.2",                                                                           
        "ansible": "0.24.1",                                                                          
        "certguard": "3.63.11",                                                                       
        "container": "2.23.0"                                                                         
      },                                 

Describe the bug
We recently upgraded from 3.17 to 3.63 (hitting every 3.xx release along the way, making sure migrations succeed, etc.) and have been seeing a lot of 500's in general. For example, when simply trying to list a user's roles, we get a 500 error. Note that we are not using domains... when I try to list a user's roles in the default domain, I don't get a 500, but I also don't get any results.

$ pulp user role-assignment list --username <username>
Error: 
<!doctype html>
<html lang="en">
<head>
  <title>Server Error (500)</title>
</head>
<body>
  <h1>Server Error (500)</h1><p></p>
</body>
</html>

On the API pod we see:

pulp [df4fa86a4bfb4c4987141111b6fc8991]: django.request:ERROR: Internal Server Error: /pulp/api/v3/users/23/roles/
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.9/site-packages/django/core/handlers/base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/local/lib/python3.9/site-packages/django/views/decorators/csrf.py", line 56, in wrapper_view
    return view_func(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/rest_framework/viewsets.py", line 124, in view
    return self.dispatch(request, *args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/rest_framework/views.py", line 509, in dispatch
    response = self.handle_exception(exc)
  File "/usr/local/lib/python3.9/site-packages/rest_framework/views.py", line 469, in handle_exception
    self.raise_uncaught_exception(exc)
  File "/usr/local/lib/python3.9/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
    raise exc
  File "/usr/local/lib/python3.9/site-packages/rest_framework/views.py", line 506, in dispatch
    response = handler(request, *args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/rest_framework/mixins.py", line 43, in list
    return self.get_paginated_response(serializer.data)
  File "/usr/local/lib/python3.9/site-packages/rest_framework/serializers.py", line 795, in data
    ret = super().data
  File "/usr/local/lib/python3.9/site-packages/rest_framework/serializers.py", line 249, in data
    self._data = self.to_representation(self.instance)
  File "/usr/local/lib/python3.9/site-packages/rest_framework/serializers.py", line 713, in to_representation
    return [
  File "/usr/local/lib/python3.9/site-packages/rest_framework/serializers.py", line 714, in <listcomp>
    self.child.to_representation(item) for item in iterable
  File "/usr/local/lib/python3.9/site-packages/rest_framework/serializers.py", line 538, in to_representation
    ret[field.field_name] = field.to_representation(attribute)
  File "/usr/local/lib/python3.9/site-packages/pulpcore/app/serializers/user.py", line 69, in to_representation
    serializer = viewset.serializer_class(obj.content_object, context={"request": request})
TypeError: 'NoneType' object is not callable
('pulp [df4fa86a4bfb4c4987141111b6fc8991]: ::ffff:10.42.47.21 - admin [05/Mar/2025:21:38:41 +0000] "GET /pulp/api/v3/users/23/roles/?offset=0&limit=25 HTTP/1.1" 500 145 "-" "Pulp-CLI/0.31.0"',)

Note that trying to use the API directly gives the same 500 so it doesn't seem to be a CLI issue.

To Reproduce
Just try to get a user's role as described above.

Expected behavior
Pulp should return the user's roles.

Additional context
Like I said, we recently upgraded, so is it possible something got missed in a migration?

@mdellweg
Copy link
Member

mdellweg commented Mar 6, 2025

From the trace back i read that the serializer_class of the objects viewset seems to be None. It would be helpful to know what kind of object this was. Any possibility that your upgraded container ships less plugins than the one before?

I was not able to reproduce this either with nor without an assigned object:

pulp -poci user role-assignment list --username admin
[
  {
    "pulp_href": "/pulp/api/v3/users/1/roles/01956c38-c3dd-796d-80d2-366ec4a84a82/",
    "prn": "prn:core.userrole:01956c38-c3dd-796d-80d2-366ec4a84a82",
    "pulp_created": "2025-03-06T16:10:14.366445Z",
    "pulp_last_updated": "2025-03-06T16:10:14.366455Z",
    "role": "file.filerepository_owner",
    "content_object": "/pulp/api/v3/repositories/file/file/01956c38-c3d7-7a97-8a63-45fd0b0980e1/",
    "description": null,
    "permissions": [
      "file.change_filerepository",
      "file.delete_filerepository",
      "file.manage_roles_filerepository",
      "file.modify_filerepository",
      "file.repair_filerepository",
      "file.sync_filerepository",
      "file.view_filerepository"
    ],
    "domain": null
  },
  {
    "pulp_href": "/pulp/api/v3/users/1/roles/01956c35-6116-7150-82ed-bad3b2e942b3/",
    "prn": "prn:core.userrole:01956c35-6116-7150-82ed-bad3b2e942b3",
    "pulp_created": "2025-03-06T16:06:32.471802Z",
    "pulp_last_updated": "2025-03-06T16:06:32.471812Z",
    "role": "file.filedistribution_viewer",
    "content_object": null,
    "description": null,
    "permissions": [
      "file.view_filedistribution"
    ],
    "domain": null
  }
]

@grzleadams
Copy link
Author

We're using the pulp-minimal image pulled off the quay registry so if there are missing plugins, then it's a Pulp oci-images build issue. I'm not sure what you mean by what object type it was; I'm just trying to list a user's role and getting the 500, so let me know how I can clarify further. Thanks!

@grzleadams
Copy link
Author

If you're asking what other object types we've seen it on, maybe this is related? And we've also seen it on pulp_file uploads but I didn't open an issue for that yet.

mdellweg added a commit to mdellweg/pulpcore that referenced this issue Mar 6, 2025
This also adds a corresponding PRN field.

fixes pulp#6330
@mdellweg mdellweg linked a pull request Mar 6, 2025 that will close this issue
@mdellweg
Copy link
Member

mdellweg commented Mar 6, 2025

Can you try applying this change in the container to see if it solves the problem?

#6334

mdellweg added a commit to mdellweg/pulpcore that referenced this issue Mar 6, 2025
This also adds a corresponding PRN field.

fixes pulp#6330
@grzleadams
Copy link
Author

How can I apply the change? Just overwrite user.py and util.py? Aren't they already loaded into memory?

@mdellweg
Copy link
Member

mdellweg commented Mar 7, 2025

Yeah, you probably need to start a modified container. I don't see an easy way, sorry. But I don't have another way to verify this is a fix.

@grzleadams
Copy link
Author

Sorry for the silence on this... how can I build an image to test with?

@mdellweg
Copy link
Member

np
You could look at the pulp-oci-images repository and use the Container files there.

Here's a (hopefully still valid) guide:
https://pulpproject.org/pulp-oci-images/docs/admin/guides/build-your-own-pulp-image/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants