Skip to content

Error adding a role in the Admin screen with an empty parameter list #63

@stgraham2000

Description

@stgraham2000

Using Django 2.2.15 and just the django-prbac app installed, I tried to add a new role from the admin screen with an empty parameter list and received the following exception:

Internal Server Error: /admin/django_prbac/role/add/
Traceback (most recent call last):
  File "/Users/sgraham/.local/share/virtualenvs/temp2-ec52t3-K/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/Users/sgraham/.local/share/virtualenvs/temp2-ec52t3-K/lib/python3.7/site-packages/django/core/handlers/base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/Users/sgraham/.local/share/virtualenvs/temp2-ec52t3-K/lib/python3.7/site-packages/django/core/handlers/base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/Users/sgraham/.local/share/virtualenvs/temp2-ec52t3-K/lib/python3.7/site-packages/django/contrib/admin/options.py", line 606, in wrapper
    return self.admin_site.admin_view(view)(*args, **kwargs)
  File "/Users/sgraham/.local/share/virtualenvs/temp2-ec52t3-K/lib/python3.7/site-packages/django/utils/decorators.py", line 142, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/Users/sgraham/.local/share/virtualenvs/temp2-ec52t3-K/lib/python3.7/site-packages/django/views/decorators/cache.py", line 44, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File "/Users/sgraham/.local/share/virtualenvs/temp2-ec52t3-K/lib/python3.7/site-packages/django/contrib/admin/sites.py", line 223, in inner
    return view(request, *args, **kwargs)
  File "/Users/sgraham/.local/share/virtualenvs/temp2-ec52t3-K/lib/python3.7/site-packages/django/contrib/admin/options.py", line 1645, in add_view
    return self.changeform_view(request, None, form_url, extra_context)
  File "/Users/sgraham/.local/share/virtualenvs/temp2-ec52t3-K/lib/python3.7/site-packages/django/utils/decorators.py", line 45, in _wrapper
    return bound_method(*args, **kwargs)
  File "/Users/sgraham/.local/share/virtualenvs/temp2-ec52t3-K/lib/python3.7/site-packages/django/utils/decorators.py", line 142, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/Users/sgraham/.local/share/virtualenvs/temp2-ec52t3-K/lib/python3.7/site-packages/django/contrib/admin/options.py", line 1529, in changeform_view
    return self._changeform_view(request, object_id, form_url, extra_context)
  File "/Users/sgraham/.local/share/virtualenvs/temp2-ec52t3-K/lib/python3.7/site-packages/django/contrib/admin/options.py", line 1572, in _changeform_view
    self.save_model(request, new_object, form, not add)
  File "/Users/sgraham/.local/share/virtualenvs/temp2-ec52t3-K/lib/python3.7/site-packages/django/contrib/admin/options.py", line 1088, in save_model
    obj.save()
  File "/Users/sgraham/.local/share/virtualenvs/temp2-ec52t3-K/lib/python3.7/site-packages/django_prbac/models.py", line 30, in save
    super(ValidatingModel, self).save(force_insert, force_update, **kwargs)
  File "/Users/sgraham/.local/share/virtualenvs/temp2-ec52t3-K/lib/python3.7/site-packages/django/db/models/base.py", line 741, in save
    force_update=force_update, update_fields=update_fields)
  File "/Users/sgraham/.local/share/virtualenvs/temp2-ec52t3-K/lib/python3.7/site-packages/django/db/models/base.py", line 779, in save_base
    force_update, using, update_fields,
  File "/Users/sgraham/.local/share/virtualenvs/temp2-ec52t3-K/lib/python3.7/site-packages/django/db/models/base.py", line 870, in _save_table
    result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
  File "/Users/sgraham/.local/share/virtualenvs/temp2-ec52t3-K/lib/python3.7/site-packages/django/db/models/base.py", line 908, in _do_insert
    using=using, raw=raw)
  File "/Users/sgraham/.local/share/virtualenvs/temp2-ec52t3-K/lib/python3.7/site-packages/django/db/models/manager.py", line 82, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/Users/sgraham/.local/share/virtualenvs/temp2-ec52t3-K/lib/python3.7/site-packages/django/db/models/query.py", line 1186, in _insert
    return query.get_compiler(using=using).execute_sql(return_id)
  File "/Users/sgraham/.local/share/virtualenvs/temp2-ec52t3-K/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 1374, in execute_sql
    for sql, params in self.as_sql():
  File "/Users/sgraham/.local/share/virtualenvs/temp2-ec52t3-K/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 1318, in as_sql
    for obj in self.query.objs
  File "/Users/sgraham/.local/share/virtualenvs/temp2-ec52t3-K/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 1318, in <listcomp>
    for obj in self.query.objs
  File "/Users/sgraham/.local/share/virtualenvs/temp2-ec52t3-K/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 1317, in <listcomp>
    [self.prepare_value(field, self.pre_save_val(field, obj)) for field in fields]
  File "/Users/sgraham/.local/share/virtualenvs/temp2-ec52t3-K/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 1258, in prepare_value
    value = field.get_db_prep_save(value, connection=self.connection)
  File "/Users/sgraham/.local/share/virtualenvs/temp2-ec52t3-K/lib/python3.7/site-packages/django/db/models/fields/__init__.py", line 793, in get_db_prep_save
    return self.get_db_prep_value(value, connection=connection, prepared=False)
  File "/Users/sgraham/.local/share/virtualenvs/temp2-ec52t3-K/lib/python3.7/site-packages/django/db/models/fields/__init__.py", line 788, in get_db_prep_value
    value = self.get_prep_value(value)
  File "/Users/sgraham/.local/share/virtualenvs/temp2-ec52t3-K/lib/python3.7/site-packages/django_prbac/fields.py", line 99, in get_prep_value
    raise ValueError('Invalid value %r for StringSetField' % value)
ValueError: Invalid value [] for StringSetField```

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions