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

AttributeError: NoneType object has no attribute strip during link translation #2485

Closed
timobrembeck opened this issue Oct 26, 2023 · 1 comment · Fixed by #2487
Closed
Assignees
Labels
🐛 bug Something isn't working 🆘 prio: urgent Needs to be resolved now(?)
Milestone

Comments

@timobrembeck
Copy link
Member

Describe the Bug

The new link translation feature introduced in #2403 seems to have a problem.

Steps to Reproduce

  1. Go to /marburg-biedenkopf/pages/de-si/13080/edit/
  2. Do something?
  3. Save formn
  4. See error

Expected Behavior

The form should be saved and the links should be automatically translated if the corresponding checkboxes are enabled

Actual Behavior

An internal server error occurs

Additional Information

Traceback
Oct 26 09:16:03 ERROR   django.request - 500 Internal Server Error: /marburg-biedenkopf/pages/de-si/13080/edit/
Traceback (most recent call last):
File "/opt/integreat-cms/.venv/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner
  response = get_response(request)
File "/opt/integreat-cms/.venv/lib/python3.9/site-packages/django/core/handlers/base.py", line 181, in _get_response
  response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/opt/integreat-cms/.venv/lib/python3.9/site-packages/django/views/generic/base.py", line 70, in view
  return self.dispatch(request, *args, **kwargs)
File "/opt/integreat-cms/.venv/lib/python3.9/site-packages/django/utils/decorators.py", line 43, in _wrapper
  return bound_method(*args, **kwargs)
File "/opt/integreat-cms/.venv/lib/python3.9/site-packages/django/contrib/auth/decorators.py", line 21, in _wrapped_view
  return view_func(request, *args, **kwargs)
File "/opt/integreat-cms/.venv/lib/python3.9/site-packages/django/views/generic/base.py", line 98, in dispatch
  return handler(request, *args, **kwargs)
File "/usr/lib/python3.9/contextlib.py", line 79, in inner
  return func(*args, **kwds)
File "/opt/integreat-cms/.venv/lib/python3.9/site-packages/integreat_cms/cms/views/pages/page_form_view.py", line 305, in post
  if not page_form.is_valid() or not page_translation_form.is_valid():
File "/opt/integreat-cms/.venv/lib/python3.9/site-packages/django/forms/forms.py", line 175, in is_valid
  return self.is_bound and not self.errors
File "/opt/integreat-cms/.venv/lib/python3.9/site-packages/django/forms/forms.py", line 170, in errors
  self.full_clean()
File "/opt/integreat-cms/.venv/lib/python3.9/site-packages/django/forms/forms.py", line 372, in full_clean
  self._clean_fields()
File "/opt/integreat-cms/.venv/lib/python3.9/site-packages/django/forms/forms.py", line 393, in _clean_fields
  value = getattr(self, 'clean_%s' % name)()
File "/opt/integreat-cms/.venv/lib/python3.9/site-packages/integreat_cms/cms/forms/custom_content_model_form.py", line 132, in clean_content
  if translation := internal_link_utils.update_link_language(
File "/opt/integreat-cms/.venv/lib/python3.9/site-packages/integreat_cms/cms/utils/internal_link_utils.py", line 55, in update_link_language
  if source_translation.title.lower() == link_text.strip().lower():
AttributeError: 'NoneType' object has no attribute 'strip'
@timobrembeck timobrembeck added 🐛 bug Something isn't working 🆘 prio: urgent Needs to be resolved now(?) labels Oct 26, 2023
@timobrembeck timobrembeck added this to the 23Q4 milestone Oct 26, 2023
@timobrembeck timobrembeck self-assigned this Oct 26, 2023
@timobrembeck
Copy link
Member Author

The culprit was a link with HTML tags in the link text:

<a href="https://integreat.app/marburg-biedenkopf/de/sprache/sprachkurse/online-sprachkurse"><strong>Online-Angebote</strong></a>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working 🆘 prio: urgent Needs to be resolved now(?)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant