Actions
Issue #8500
closedAn internal error is raised when assigning permissions to a non-existing object
Start date:
Due date:
Estimated time:
Severity:
2. Medium
Version:
Platform Release:
OS:
Triaged:
Yes
Groomed:
No
Sprint Candidate:
No
Tags:
Sprint:
Sprint 101
Quarter:
Description
Steps to reproduce the behaviour:
(pulp) [vagrant@pulp3-source-fedora32 ~]$ pulp group create --name cli_test_group
{
"name": "cli_test_group",
"pulp_href": "/pulp/api/v3/groups/1/",
"id": 1
}
(pulp) [vagrant@pulp3-source-fedora32 ~]$ pulp group permission add --groupname cli_test_group --permission auth.view_group
(pulp) [vagrant@pulp3-source-fedora32 ~]$ pulp group permission list --groupname cli_test_group
[
{
"pulp_href": "/pulp/api/v3/groups/1/model_permissions/12/",
"id": 12,
"permission": "auth.view_group",
"obj": null
}
]
(pulp) [vagrant@pulp3-source-fedora32 ~]$ pulp group permission -t object add --groupname cli_test_group --permission file.view_filerepository --object /pulp/api/v3/repositories/file/file/44d1a790-27db-4e40-8903-1dead247dd0e/
Error: <h1>Server Error (500)</h1>
Traceback:
Traceback (most recent call last):
File "/usr/local/lib/pulp/lib64/python3.8/site-packages/django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "/usr/local/lib/pulp/lib64/python3.8/site-packages/django/core/handlers/base.py", line 115, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/usr/local/lib/pulp/lib64/python3.8/site-packages/django/core/handlers/base.py", line 113, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/pulp/lib64/python3.8/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
return view_func(*args, **kwargs)
File "/usr/local/lib/pulp/lib64/python3.8/site-packages/rest_framework/viewsets.py", line 125, in view
return self.dispatch(request, *args, **kwargs)
File "/usr/local/lib/pulp/lib64/python3.8/site-packages/rest_framework/views.py", line 509, in dispatch
response = self.handle_exception(exc)
File "/usr/local/lib/pulp/lib64/python3.8/site-packages/rest_framework/views.py", line 469, in handle_exception
self.raise_uncaught_exception(exc)
File "/usr/local/lib/pulp/lib64/python3.8/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
raise exc
File "/usr/local/lib/pulp/lib64/python3.8/site-packages/rest_framework/views.py", line 506, in dispatch
response = handler(request, *args, **kwargs)
File "/home/vagrant/devel/pulpcore/pulpcore/app/viewsets/user.py", line 333, in create
object_permission.save()
File "/usr/local/lib/pulp/lib64/python3.8/site-packages/guardian/models/models.py", line 29, in save
content_type = get_content_type(self.content_object)
File "/usr/local/lib/pulp/lib64/python3.8/site-packages/guardian/ctypes.py", line 10, in get_content_type
return get_content_type_function(obj)
File "/usr/local/lib/pulp/lib64/python3.8/site-packages/guardian/ctypes.py", line 14, in get_default_content_type
return ContentType.objects.get_for_model(obj)
File "/usr/local/lib/pulp/lib64/python3.8/site-packages/django/contrib/contenttypes/models.py", line 40, in get_for_model
opts = self._get_opts(model, for_concrete_model)
File "/usr/local/lib/pulp/lib64/python3.8/site-packages/django/contrib/contenttypes/models.py", line 27, in _get_opts
model = model._meta.concrete_model
AttributeError: 'NoneType' object has no attribute '_meta'
Updated by daviddavis over 3 years ago
- Subject changed from CLI: An internal error is raised when assigning permissions to a non-existing object to An internal error is raised when assigning permissions to a non-existing object
- Triaged changed from No to Yes
- Sprint set to Sprint 94
Updated by lmjachky over 3 years ago
- Status changed from NEW to ASSIGNED
- Assignee set to lmjachky
Updated by lmjachky over 3 years ago
Similarly, an internal server error is raised when assigning permissions to an already assigned object:
Traceback (most recent call last):
File "/usr/local/lib/pulp/lib64/python3.9/site-packages/django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "/usr/local/lib/pulp/lib64/python3.9/site-packages/django/core/handlers/base.py", line 115, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/usr/local/lib/pulp/lib64/python3.9/site-packages/django/core/handlers/base.py", line 113, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/pulp/lib64/python3.9/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
return view_func(*args, **kwargs)
File "/usr/local/lib/pulp/lib64/python3.9/site-packages/rest_framework/viewsets.py", line 125, in view
return self.dispatch(request, *args, **kwargs)
File "/usr/local/lib/pulp/lib64/python3.9/site-packages/rest_framework/views.py", line 509, in dispatch
response = self.handle_exception(exc)
File "/usr/local/lib/pulp/lib64/python3.9/site-packages/rest_framework/views.py", line 469, in handle_exception
self.raise_uncaught_exception(exc)
File "/usr/local/lib/pulp/lib64/python3.9/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
raise exc
File "/usr/local/lib/pulp/lib64/python3.9/site-packages/rest_framework/views.py", line 506, in dispatch
response = handler(request, *args, **kwargs)
File "/home/vagrant/devel/pulpcore/pulpcore/app/viewsets/user.py", line 343, in create
object_permission.save()
File "/usr/local/lib/pulp/lib64/python3.9/site-packages/guardian/models/models.py", line 34, in save
return super().save(*args, **kwargs)
File "/usr/local/lib/pulp/lib64/python3.9/site-packages/django/db/models/base.py", line 743, in save
self.save_base(using=using, force_insert=force_insert,
File "/usr/local/lib/pulp/lib64/python3.9/site-packages/django/db/models/base.py", line 780, in save_base
updated = self._save_table(
File "/usr/local/lib/pulp/lib64/python3.9/site-packages/django/db/models/base.py", line 873, in _save_table
result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
File "/usr/local/lib/pulp/lib64/python3.9/site-packages/django/db/models/base.py", line 910, in _do_insert
return manager._insert([self], fields=fields, return_id=update_pk,
File "/usr/local/lib/pulp/lib64/python3.9/site-packages/django/db/models/manager.py", line 82, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/usr/local/lib/pulp/lib64/python3.9/site-packages/django/db/models/query.py", line 1186, in _insert
return query.get_compiler(using=using).execute_sql(return_id)
File "/usr/local/lib/pulp/lib64/python3.9/site-packages/django/db/models/sql/compiler.py", line 1377, in execute_sql
cursor.execute(sql, params)
File "/usr/local/lib/pulp/lib64/python3.9/site-packages/django/db/backends/utils.py", line 67, in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "/usr/local/lib/pulp/lib64/python3.9/site-packages/django/db/backends/utils.py", line 76, in _execute_with_wrappers
return executor(sql, params, many, context)
File "/usr/local/lib/pulp/lib64/python3.9/site-packages/django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
File "/usr/local/lib/pulp/lib64/python3.9/site-packages/django/db/utils.py", line 89, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/usr/local/lib/pulp/lib64/python3.9/site-packages/django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
django.db.utils.IntegrityError: duplicate key value violates unique constraint "guardian_groupobjectperm_group_id_permission_id_o_3f189f7c_uniq"
DETAIL: Key (group_id, permission_id, object_pk)=(1, 276, b291dcbf-7eca-4cdd-86b4-62628febe713) already exists.
pulp [dfb7c6ca32ef4827aca96dadd10d98cb]: 127.0.0.1 - admin [07/Jul/2021:11:23:40 +0000] "POST /pulp/api/v3/groups/1/object_permissions/ HTTP/1.0" 500 27 "-" "python-requests/2.25.1"
Updated by pulpbot over 3 years ago
- Status changed from ASSIGNED to POST
Added by Lubos Mjachky over 3 years ago
Updated by Anonymous over 3 years ago
- Status changed from POST to MODIFIED
Applied in changeset pulpcore|f4e5751ec8da208730c700e6c94b2d10a7d90e41.
Updated by pulpbot about 3 years ago
- Status changed from MODIFIED to CLOSED - CURRENTRELEASE
Actions
Validate objects in GroupObjectPermissionViewSet
closes #8500