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

'NoneType' object has no attribute 'set' error #6672

Closed
wirthandras opened this issue Oct 14, 2021 · 10 comments
Closed

'NoneType' object has no attribute 'set' error #6672

wirthandras opened this issue Oct 14, 2021 · 10 comments
Assignees
Labels
bug Something is broken.
Milestone

Comments

@wirthandras
Copy link
Contributor

Hi, We are using XLIFF v1.2 format via git source control.
The intermediate language comes from branch "X" and the output branch is "Y"

The source review process run out without reported problem. (Intermediate language to English US)
But at Spanish translation process the user get an error. (English US -> Spanish US)

No clue what user did exactly. Some of texts has XML markup.
We assume the User saved one or more string with incorrect xml format.

If we try to save this text on Spanish(US) version the error occured:

simple text: <x id="START_LINK" ctype="x-a" equiv-text="&lt;a href=&quot;https://validurl.com/&quot;&gt;"/>https://validurl.com/<x id="CLOSE_LINK" ctype="x-a" equiv-text="&lt;/a&gt;"/> 

This text saved without problem at source review.

An other string has an "<" which is first character of an incorrect xml part in Spanish translation

Some texts which has markup could be not saved, the errors come up.
The simple texts which has no any special formatting can be saved.

The biggest pain, it seems any of xml exports does not work, we cannot do a commit and push back to repository. (Same error occurs)
We tested the manual JSON export, it is works as expected.

I already tried

We tried to delete the problematic texts from weblate manually to expecting the xml exporters come back to work, but without success.
When we do a delete on the specific text the same error occurs

Environment: Docker compose install: Weblate version 4.6.1
Exception traceback

Request Method: POST
Request URL: https://url/commit/project/component/

Django Version: 3.2
Python Version: 3.7.3
Installed Applications:
['customize',
'weblate.addons',
'weblate.auth',
'weblate.checks',
'weblate.formats',
'weblate.glossary',
'weblate.machinery',
'weblate.trans',
'weblate.lang',
'weblate_language_data',
'weblate.memory',
'weblate.screenshots',
'weblate.fonts',
'weblate.accounts',
'weblate.configuration',
'weblate.utils',
'weblate.vcs',
'weblate.wladmin',
'weblate.metrics',
'weblate',
'weblate.gitexport',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin.apps.SimpleAdminConfig',
'django.contrib.admindocs',
'django.contrib.sitemaps',
'django.contrib.humanize',
'social_django',
'crispy_forms',
'compressor',
'rest_framework',
'rest_framework.authtoken',
'django_filters']
Installed Middleware:
['weblate.middleware.RedirectMiddleware',
'weblate.middleware.ProxyMiddleware',
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'weblate.accounts.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'social_django.middleware.SocialAuthExceptionMiddleware',
'weblate.accounts.middleware.RequireLoginMiddleware',
'weblate.api.middleware.ThrottlingMiddleware',
'weblate.middleware.SecurityMiddleware']

Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
File "/usr/local/lib/python3.7/dist-packages/django/core/handlers/base.py", line 181, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python3.7/dist-packages/django/contrib/auth/decorators.py", line 21, in _wrapped_view
return view_func(request, *args, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/django/views/decorators/http.py", line 40, in inner
return func(request, *args, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/weblate/trans/views/git.py", line 138, in commit_component
return perform_commit(request, obj)
File "/usr/local/lib/python3.7/dist-packages/weblate/trans/views/git.py", line 60, in perform_commit
request.user,
File "/usr/local/lib/python3.7/dist-packages/weblate/trans/views/git.py", line 35, in execute_locked
result = call(*args, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/weblate/trans/models/component.py", line 154, in on_link_wrapper
return func(self, *args, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/weblate/trans/models/component.py", line 1543, in commit_pending
reason, user, skip_push=True, force=True, signals=False
File "/usr/lib/python3.7/contextlib.py", line 74, in inner
return func(*args, **kwds)
File "/usr/local/lib/python3.7/dist-packages/weblate/trans/models/translation.py", line 540, in commit_pending
self.update_units(units, store, author_name, author.id)
File "/usr/local/lib/python3.7/dist-packages/weblate/trans/models/translation.py", line 666, in update_units
pounit.set_state(unit.state)
File "/usr/local/lib/python3.7/dist-packages/weblate/formats/ttkit.py", line 680, in set_state
self.xliff_node.set("state", "needs-translation")

Exception Type: AttributeError at /commit/princess-house/consultant-corner-frontend/
Exception Value: 'NoneType' object has no attribute 'set'

Server configuration and status

Weblate installation: Docker

Any idea? Could we get out from stucked state?

Thanks!

@nijel nijel self-assigned this Oct 15, 2021
@nijel nijel added the bug Something is broken. label Oct 15, 2021
@nijel nijel added this to the 4.7.2 milestone Oct 15, 2021
@nijel
Copy link
Member

nijel commented Oct 15, 2021

Any idea?

Please upgrade, this should be already fixed by b6d4c57.

@nijel nijel closed this as completed Oct 15, 2021
@github-actions
Copy link

Thank you for your report; the issue you have reported has just been fixed.

  • In case you see a problem with the fix, please comment on this issue.
  • In case you see a similar problem, please open a separate issue.
  • If you are happy with the outcome, don’t hesitate to support Weblate by making a donation.

@wirthandras
Copy link
Contributor Author

@nijel sorry to say, we did an update to 4.8.1 but the problem still exists, the error message is the same

@nijel nijel reopened this Oct 20, 2021
@nijel
Copy link
Member

nijel commented Oct 20, 2021

Can you please share traceback from 4.8.1?

@nijel nijel modified the milestones: 4.7.2, 4.9 Oct 20, 2021
@wirthandras
Copy link
Contributor Author

wirthandras commented Oct 20, 2021

We did:
docker-compose stop
docker-compose pull
docker-compose up

Then in app when saving specific text, the following error occured?

Environment:

Request Method: POST
Request URL: https://url/translate/urlpart/?q=state%3A%3Ctranslated&offset=1

Django Version: 3.2.7
Python Version: 3.9.2
Installed Applications:
['customize',
'weblate.addons',
'weblate.auth',
'weblate.checks',
'weblate.formats',
'weblate.glossary',
'weblate.machinery',
'weblate.trans',
'weblate.lang',
'weblate_language_data',
'weblate.memory',
'weblate.screenshots',
'weblate.fonts',
'weblate.accounts',
'weblate.configuration',
'weblate.utils',
'weblate.vcs',
'weblate.wladmin',
'weblate.metrics',
'weblate',
'weblate.gitexport',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin.apps.SimpleAdminConfig',
'django.contrib.admindocs',
'django.contrib.sitemaps',
'django.contrib.humanize',
'social_django',
'crispy_forms',
'compressor',
'rest_framework',
'rest_framework.authtoken',
'django_filters']
Installed Middleware:
['weblate.middleware.RedirectMiddleware',
'weblate.middleware.ProxyMiddleware',
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'weblate.accounts.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'social_django.middleware.SocialAuthExceptionMiddleware',
'weblate.accounts.middleware.RequireLoginMiddleware',
'weblate.api.middleware.ThrottlingMiddleware',
'weblate.middleware.SecurityMiddleware']

Traceback (most recent call last):
File "/usr/local/lib/python3.9/dist-packages/django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
File "/usr/local/lib/python3.9/dist-packages/django/core/handlers/base.py", line 181, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python3.9/dist-packages/weblate/trans/views/edit.py", line 589, in translate
response = handle_translate(request, unit, this_unit_url, next_unit_url)
File "/usr/local/lib/python3.9/dist-packages/weblate/utils/ratelimit.py", line 118, in rate_wrap
return function(request, *args, **kwargs)
File "/usr/local/lib/python3.9/dist-packages/weblate/trans/views/edit.py", line 403, in handle_translate
go_next = perform_translation(unit, form, request)
File "/usr/local/lib/python3.9/dist-packages/weblate/trans/views/edit.py", line 317, in perform_translation
saved = unit.translate(
File "/usr/lib/python3.9/contextlib.py", line 79, in inner
return func(*args, **kwds)
File "/usr/local/lib/python3.9/dist-packages/weblate/trans/models/unit.py", line 1262, in translate
saved = self.save_backend(
File "/usr/local/lib/python3.9/dist-packages/weblate/trans/models/unit.py", line 903, in save_backend
self.translation.commit_pending("pending unit", None)
File "/usr/lib/python3.9/contextlib.py", line 79, in inner
return func(*args, **kwds)
File "/usr/local/lib/python3.9/dist-packages/weblate/trans/models/translation.py", line 559, in commit_pending
self.update_units(units, store, author_name, author.id)
File "/usr/local/lib/python3.9/dist-packages/weblate/trans/models/translation.py", line 682, in update_units
pounit.set_state(unit.state)
File "/usr/local/lib/python3.9/dist-packages/weblate/formats/ttkit.py", line 689, in set_state
self.xliff_node.set("state", "needs-translation")

Exception Type: AttributeError at /translate/url/translate/urlpart/es_US/
Exception Value: 'NoneType' object has no attribute 'set'

@wirthandras
Copy link
Contributor Author

@nijel additional info: we dindt do any magic, but the automatic push to branch is works, but I dont know why, only the manual commit broken, we did a fresh install on a sandbox with 4.8.1, and it seems the problem not occurs. Could be something stucked?

@nijel
Copy link
Member

nijel commented Oct 20, 2021

The problem is that there is some string marked as need editing which cannot be saved. Do you also get HTML mails with the traceback? Seeing local variables from update_units and set_state could help to diagnose this.

@wirthandras
Copy link
Contributor Author

@nijel we totally re-installed our weblate production environment with version 4.8.1, the described problem does not introduce anymore.

It seems to me the Docker Upgrade action does not fix the problem, could be it was data related error.

I close the issue

@github-actions
Copy link

Thank you for your report; the issue you have reported has just been fixed.

  • In case you see a problem with the fix, please comment on this issue.
  • In case you see a similar problem, please open a separate issue.
  • If you are happy with the outcome, don’t hesitate to support Weblate by making a donation.

@pushull
Copy link

pushull commented Sep 27, 2022

Hello there, I had the exact same problem using weblate 4.14.1-1 (last version as of today).
I tried to investigate a bit but did not find anything special.
It fails when importing a valid (checked) XLF file.
Reseting the underlying repository works but that way it is then not possible to import the given file.
The solution I used is to reinstall everything and now with the same condition it works.
So my guess would be some sort of data corruption or similar.

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

No branches or pull requests

3 participants