Skip to content
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

[bug] Error when cloning a template that already have a character count limit #797

Open
minhng99 opened this issue Jul 24, 2023 · 1 comment
Labels

Comments

@minhng99
Copy link

minhng99 commented Jul 24, 2023

Hi, I'm trying to clone a template that has a pretty long title (62 characters) but if I clone it, the new cloned template will have an added prefix (Clone) to it which makes it goes over the limit of 64 characters, resulted in Django error

==> openwisp2.log <==
[ERROR 2023-07-24 03:13:47,346] module: log, process: 862367, thread: 140614550849344
Internal Server Error: /admin/config/template/
Traceback (most recent call last):
  File "/opt/openwisp2/env/lib/python3.9/site-packages/django/core/handlers/exception.py", line 56, in inner
    response = get_response(request)
  File "/opt/openwisp2/env/lib/python3.9/site-packages/django/core/handlers/base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/opt/openwisp2/env/lib/python3.9/site-packages/django/contrib/admin/options.py", line 683, in wrapper
    return self.admin_site.admin_view(view)(*args, **kwargs)
  File "/opt/openwisp2/env/lib/python3.9/site-packages/django/utils/decorators.py", line 134, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/opt/openwisp2/env/lib/python3.9/site-packages/django/views/decorators/cache.py", line 62, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File "/opt/openwisp2/env/lib/python3.9/site-packages/django/contrib/admin/sites.py", line 242, in inner
    return view(request, *args, **kwargs)
  File "/opt/openwisp2/env/lib/python3.9/site-packages/reversion/admin.py", line 235, in changelist_view
    return super().changelist_view(request, context)
  File "/opt/openwisp2/env/lib/python3.9/site-packages/django/utils/decorators.py", line 46, in _wrapper
    return bound_method(*args, **kwargs)
  File "/opt/openwisp2/env/lib/python3.9/site-packages/django/utils/decorators.py", line 134, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/opt/openwisp2/env/lib/python3.9/site-packages/django/contrib/admin/options.py", line 1984, in changelist_view
    response = self.response_action(
  File "/opt/openwisp2/env/lib/python3.9/site-packages/django/contrib/admin/options.py", line 1589, in response_action
    response = func(self, request, queryset)
  File "/opt/openwisp2/env/lib/python3.9/site-packages/openwisp_controller/config/admin.py", line 685, in clone_selected_templates
    clone = template.clone(user)
  File "/opt/openwisp2/env/lib/python3.9/site-packages/openwisp_controller/config/base/template.py", line 208, in clone
    clone.full_clean()
  File "/opt/openwisp2/env/lib/python3.9/site-packages/django/db/models/base.py", line 1405, in full_clean
    raise ValidationError(errors)
django.core.exceptions.ValidationError: {'name': ['Ensure this value has at most 64 characters (it has 68).']}

I think we should have this exception caught and return an error message instead of spitting out 500.

@nemesifier nemesifier added the bug label Feb 7, 2024
@nemesifier
Copy link
Member

@minhng99 if you could try again with the latest master and let us know if the issue persists, it would be useful, as we did some changes to this recently and it may have been fixed.

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

No branches or pull requests

2 participants