Closed BhaaLseN closed 5 years ago
Thank you for your report, the issue you have reported should have already been fixed by https://github.com/WeblateOrg/weblate/commit/13667795dfbebba4faef9c2c8f8486c8101e969a.
Using version 3.0.1, I have the same behaviour:
Environment:
Request Method: POST
Request URL: http://<my-hosted-weblate>/commit/test/
Django Version: 2.0.6
Python Version: 3.5.2
Installed Applications:
('django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin.apps.SimpleAdminConfig',
'django.contrib.admindocs',
'django.contrib.sitemaps',
'social_django',
'crispy_forms',
'compressor',
'rest_framework',
'rest_framework.authtoken',
'weblate.addons',
'weblate.auth',
'weblate.checks',
'weblate.formats',
'weblate.machinery',
'weblate.trans',
'weblate.lang',
'weblate.langdata',
'weblate.memory',
'weblate.permissions',
'weblate.screenshots',
'weblate.accounts',
'weblate.utils',
'weblate.vcs',
'weblate.wladmin',
'weblate')
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.locale.LocaleMiddleware',
'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.middleware.SecurityMiddleware',
'weblate.wladmin.middleware.ConfigurationErrorsMiddleware']
Traceback:
File "/var/lib/weblate/venv/lib/python3.5/site-packages/django/core/handlers/exception.py" in inner
35. response = get_response(request)
File "/var/lib/weblate/venv/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response
128. response = self.process_exception_by_middleware(e, request)
File "/var/lib/weblate/venv/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response
126. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/var/lib/weblate/venv/lib/python3.5/site-packages/django/contrib/auth/decorators.py" in _wrapped_view
21. return view_func(request, *args, **kwargs)
File "/var/lib/weblate/venv/lib/python3.5/site-packages/django/views/decorators/http.py" in inner
40. return func(request, *args, **kwargs)
File "/var/lib/weblate/venv/lib/python3.5/site-packages/weblate/trans/views/git.py" in commit_project
110. return perform_commit(request, obj)
File "/var/lib/weblate/venv/lib/python3.5/site-packages/weblate/trans/views/git.py" in perform_commit
64. request,
File "/var/lib/weblate/venv/lib/python3.5/site-packages/weblate/trans/views/git.py" in execute_locked
41. result = call(*args, **kwargs)
File "/var/lib/weblate/venv/lib/python3.5/site-packages/weblate/trans/models/project.py" in commit_pending
258. component.commit_pending(request, skip_push=True)
File "/var/lib/weblate/venv/lib/python3.5/site-packages/weblate/trans/models/component.py" in commit_pending
797. component.commit_pending(request, True, skip_push=True)
File "/var/lib/weblate/venv/lib/python3.5/site-packages/weblate/trans/models/component.py" in commit_pending
793. translation.commit_pending(request, skip_push=True)
File "/var/lib/weblate/venv/lib/python3.5/site-packages/weblate/trans/models/translation.py" in commit_pending
426. self.update_units(author_name, change.author.id)
File "/usr/lib/python3.5/contextlib.py" in inner
30. return func(*args, **kwds)
File "/var/lib/weblate/venv/lib/python3.5/site-packages/weblate/trans/models/translation.py" in update_units
528. unit_change = unit.change_set.content().order_by('-timestamp')[0]
File "/var/lib/weblate/venv/lib/python3.5/site-packages/django/db/models/query.py" in __getitem__
307. return qs._result_cache[0]
Exception Type: IndexError at /commit/test/
Exception Value: list index out of range
That looks like some inconsistency in the database. Is it on fresh install or was it upgraded?
Fresh installation. I don't know if it can be related, but I have done many manipulations (only through UI) to find the correct settings. Like various tests of the addon Component discovery.
That should not cause any such problems...
I update my code with the changes you made in 87bbaeb and still have the error. Once while updating an existing translation (new translation pass), once while committing changes.
Stacktrace of the update of existing translation
Environment:
Request Method: POST
Request URL: http://<my-hosted-weblate/translate/test/test-products/fr/?type=translated&offset=0
Django Version: 2.0.6
Python Version: 3.5.2
Installed Applications:
('django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin.apps.SimpleAdminConfig',
'django.contrib.admindocs',
'django.contrib.sitemaps',
'social_django',
'crispy_forms',
'compressor',
'rest_framework',
'rest_framework.authtoken',
'weblate.addons',
'weblate.auth',
'weblate.checks',
'weblate.formats',
'weblate.machinery',
'weblate.trans',
'weblate.lang',
'weblate.langdata',
'weblate.memory',
'weblate.permissions',
'weblate.screenshots',
'weblate.accounts',
'weblate.utils',
'weblate.vcs',
'weblate.wladmin',
'weblate')
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.locale.LocaleMiddleware',
'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.middleware.SecurityMiddleware',
'weblate.wladmin.middleware.ConfigurationErrorsMiddleware']
Traceback:
File "/var/lib/weblate/venv/lib/python3.5/site-packages/django/core/handlers/exception.py" in inner
35. response = get_response(request)
File "/var/lib/weblate/venv/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response
128. response = self.process_exception_by_middleware(e, request)
File "/var/lib/weblate/venv/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response
126. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/var/lib/weblate/venv/lib/python3.5/site-packages/weblate/trans/views/edit.py" in translate
518. this_unit_url, next_unit_url
File "/var/lib/weblate/venv/lib/python3.5/site-packages/weblate/trans/views/edit.py" in handle_translate
322. go_next = perform_translation(unit, form, request)
File "/var/lib/weblate/venv/lib/python3.5/site-packages/weblate/trans/views/edit.py" in perform_translation
252. form.cleaned_data['state']
File "/usr/lib/python3.5/contextlib.py" in inner
30. return func(*args, **kwds)
File "/var/lib/weblate/venv/lib/python3.5/site-packages/weblate/trans/models/unit.py" in translate
1047. propagate=propagate
File "/var/lib/weblate/venv/lib/python3.5/site-packages/weblate/trans/models/unit.py" in save_backend
623. self.propagate(request, change_action)
File "/var/lib/weblate/venv/lib/python3.5/site-packages/weblate/trans/models/unit.py" in propagate
588. unit.save_backend(request, False, change_action=change_action)
File "/var/lib/weblate/venv/lib/python3.5/site-packages/weblate/trans/models/unit.py" in save_backend
606. change = self.change_set.content().order_by('-timestamp')[0]
File "/var/lib/weblate/venv/lib/python3.5/site-packages/django/db/models/query.py" in __getitem__
307. return qs._result_cache[0]
Exception Type: IndexError at /translate/test/test-products/fr/
Exception Value: list index out of range
That commit was not really meant to fix that, it's more a cleanup which I found looking at the code here.
Odd, I never saw any issues when applying the changes of that commit (sans the typo) on my 2.20 installation. I did have to poke at the repository by forcing a (no-op, as in nothing happened) commit using the repository management, but after that it was showing the correct status and never error'd out again.
Since I'm on a QA server, I wanted to delete all components to start again. Unfortunately, I got this error for 2 components out of 6: Environment:
Request Method: POST
Request URL: http://<my-hosted-weblate>/admin/trans/component/9/delete/
Django Version: 2.0.6
Python Version: 3.5.2
Installed Applications:
('django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin.apps.SimpleAdminConfig',
'django.contrib.admindocs',
'django.contrib.sitemaps',
'social_django',
'crispy_forms',
'compressor',
'rest_framework',
'rest_framework.authtoken',
'weblate.addons',
'weblate.auth',
'weblate.checks',
'weblate.formats',
'weblate.machinery',
'weblate.trans',
'weblate.lang',
'weblate.langdata',
'weblate.memory',
'weblate.permissions',
'weblate.screenshots',
'weblate.accounts',
'weblate.utils',
'weblate.vcs',
'weblate.wladmin',
'weblate')
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.locale.LocaleMiddleware',
'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.middleware.SecurityMiddleware',
'weblate.wladmin.middleware.ConfigurationErrorsMiddleware']
Traceback:
File "/var/lib/weblate/venv/lib/python3.5/site-packages/django/core/handlers/exception.py" in inner
35. response = get_response(request)
File "/var/lib/weblate/venv/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response
128. response = self.process_exception_by_middleware(e, request)
File "/var/lib/weblate/venv/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response
126. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/var/lib/weblate/venv/lib/python3.5/site-packages/django/contrib/admin/options.py" in wrapper
575. return self.admin_site.admin_view(view)(*args, **kwargs)
File "/var/lib/weblate/venv/lib/python3.5/site-packages/django/utils/decorators.py" in _wrapped_view
142. response = view_func(request, *args, **kwargs)
File "/var/lib/weblate/venv/lib/python3.5/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
44. response = view_func(request, *args, **kwargs)
File "/var/lib/weblate/venv/lib/python3.5/site-packages/django/contrib/admin/sites.py" in inner
223. return view(request, *args, **kwargs)
File "/var/lib/weblate/venv/lib/python3.5/site-packages/django/utils/decorators.py" in _wrapper
62. return bound_func(*args, **kwargs)
File "/var/lib/weblate/venv/lib/python3.5/site-packages/django/utils/decorators.py" in _wrapped_view
142. response = view_func(request, *args, **kwargs)
File "/var/lib/weblate/venv/lib/python3.5/site-packages/django/utils/decorators.py" in bound_func
58. return func.__get__(self, type(self))(*args2, **kwargs2)
File "/var/lib/weblate/venv/lib/python3.5/site-packages/django/contrib/admin/options.py" in delete_view
1736. return self._delete_view(request, object_id, extra_context)
File "/var/lib/weblate/venv/lib/python3.5/site-packages/django/contrib/admin/options.py" in _delete_view
1769. self.delete_model(request, obj)
File "/var/lib/weblate/venv/lib/python3.5/site-packages/django/contrib/admin/options.py" in delete_model
1033. obj.delete()
File "/var/lib/weblate/venv/lib/python3.5/site-packages/django/db/models/base.py" in delete
891. return collector.delete()
File "/var/lib/weblate/venv/lib/python3.5/site-packages/django/db/models/deletion.py" in delete
307. sender=model, instance=obj, using=self.using
File "/var/lib/weblate/venv/lib/python3.5/site-packages/django/dispatch/dispatcher.py" in send
178. for receiver in self._live_receivers(sender)
File "/var/lib/weblate/venv/lib/python3.5/site-packages/django/dispatch/dispatcher.py" in <listcomp>
178. for receiver in self._live_receivers(sender)
File "/var/lib/weblate/venv/lib/python3.5/site-packages/weblate/trans/models/__init__.py" in delete_object_dir
68. shutil.rmtree(project_path)
File "/var/lib/weblate/venv/lib/python3.5/shutil.py" in rmtree
474. _rmtree_safe_fd(fd, path, onerror)
File "/var/lib/weblate/venv/lib/python3.5/shutil.py" in _rmtree_safe_fd
412. _rmtree_safe_fd(dirfd, fullname, onerror)
File "/var/lib/weblate/venv/lib/python3.5/shutil.py" in _rmtree_safe_fd
412. _rmtree_safe_fd(dirfd, fullname, onerror)
File "/var/lib/weblate/venv/lib/python3.5/shutil.py" in _rmtree_safe_fd
412. _rmtree_safe_fd(dirfd, fullname, onerror)
File "/var/lib/weblate/venv/lib/python3.5/shutil.py" in _rmtree_safe_fd
432. onerror(os.unlink, fullname, sys.exc_info())
File "/var/lib/weblate/venv/lib/python3.5/shutil.py" in _rmtree_safe_fd
430. os.unlink(name, dir_fd=topfd)
Exception Type: PermissionError at /admin/trans/component/9/delete/
Exception Value: [Errno 13] Permission denied: 'c9dce38f19a97e3a231161cd2f7864982c08d0'
Apparently some of the files have been created under different user than is running Weblate right now. You can probably recover by something like chown -R weblate:weblate /app/data/weblate
, but anyway this is offtopic here.
Thank you for your report, the issue you have reported has just been fixed.
Hello,
I am encountering a similar issue with my (docker) weblate 3.5:
weblate_1 | INFO tusky/tusky/de: committing pending changes (admin)
weblate_1 | ERROR Internal Server Error: /admin/trans/component/
weblate_1 | Traceback (most recent call last):
weblate_1 | File "/usr/local/lib/python3.6/dist-packages/django/core/handlers/exception.py", line 34, in inner
weblate_1 | response = get_response(request)
weblate_1 | File "/usr/local/lib/python3.6/dist-packages/django/core/handlers/base.py", line 126, in _get_response
weblate_1 | response = self.process_exception_by_middleware(e, request)
weblate_1 | File "/usr/local/lib/python3.6/dist-packages/django/core/handlers/base.py", line 124, in _get_response
weblate_1 | response = wrapped_callback(request, *callback_args, **callback_kwargs)
weblate_1 | File "/usr/local/lib/python3.6/dist-packages/django/contrib/admin/options.py", line 604, in wrapper
weblate_1 | return self.admin_site.admin_view(view)(*args, **kwargs)
weblate_1 | File "/usr/local/lib/python3.6/dist-packages/django/utils/decorators.py", line 142, in _wrapped_view
weblate_1 | response = view_func(request, *args, **kwargs)
weblate_1 | File "/usr/local/lib/python3.6/dist-packages/django/views/decorators/cache.py", line 44, in _wrapped_view_func
weblate_1 | response = view_func(request, *args, **kwargs)
weblate_1 | File "/usr/local/lib/python3.6/dist-packages/django/contrib/admin/sites.py", line 223, in inner
weblate_1 | return view(request, *args, **kwargs)
weblate_1 | File "/usr/local/lib/python3.6/dist-packages/django/utils/decorators.py", line 45, in _wrapper
weblate_1 | return bound_method(*args, **kwargs)
weblate_1 | File "/usr/local/lib/python3.6/dist-packages/django/utils/decorators.py", line 142, in _wrapped_view
weblate_1 | response = view_func(request, *args, **kwargs)
weblate_1 | File "/usr/local/lib/python3.6/dist-packages/django/contrib/admin/options.py", line 1701, in changelist_view
weblate_1 | response = self.response_action(request, queryset=cl.get_queryset(request))
weblate_1 | File "/usr/local/lib/python3.6/dist-packages/django/contrib/admin/options.py", line 1400, in response_action
weblate_1 | response = func(self, request, queryset)
weblate_1 | File "/usr/local/lib/python3.6/dist-packages/weblate/trans/admin.py", line 44, in force_commit
weblate_1 | obj.commit_pending('admin', request)
weblate_1 | File "/usr/local/lib/python3.6/dist-packages/weblate/trans/models/component.py", line 913, in commit_pending
weblate_1 | translation.commit_pending(reason, request, skip_push=True)
weblate_1 | File "/usr/local/lib/python3.6/dist-packages/weblate/trans/models/translation.py", line 434, in commit_pending
weblate_1 | self.update_units(author_name, change[0].id)
weblate_1 | File "/usr/lib/python3.6/contextlib.py", line 52, in inner
weblate_1 | return func(*args, **kwds)
weblate_1 | File "/usr/local/lib/python3.6/dist-packages/weblate/trans/models/translation.py", line 535, in update_units
weblate_1 | unit_change = unit.change_set.content().order_by('-timestamp')[0]
weblate_1 | File "/usr/local/lib/python3.6/dist-packages/django/db/models/query.py", line 303, in __getitem__
weblate_1 | return qs._result_cache[0]
weblate_1 | IndexError: list index out of range
Repository is configured to push as pull-requests (to github.com/Tuskyapp/Tusky from github.com/nailyk-weblate/Tusky ) We got a successful one already: https://github.com/tuskyapp/Tusky/pull/1149 Some changes have been made on both side: https://github.com/nailyk-weblate/Tusky/compare/master...tuskyapp:master
This error first happens while I tried to change the 'Age of changes to commit' into configuration (exact same error)
Any help appreciated :relaxed: Thanks in advance !
P.S.: error_email.txt attached, maybe some useful information into it. Also variables content:
After adding some debugging info into /usr/local/lib/python3.6/dist-packages/weblate/trans/models/translation.py
it seems the error is because a string is marked as replaced by the github webhook (which push changes from original repo into weblate) which does not have a username (into history of the language, the username is set to 'none' see https://weblate.nailyk.fr/projects/tusky/tusky/de/#history )
Made a dirty fix:
diff --git a/weblate/trans/models/translation.py b/weblate/trans/models/translation.py
index bc64cd5447..70f4a92294 100644
--- a/weblate/trans/models/translation.py
+++ b/weblate/trans/models/translation.py
@@ -532,6 +532,14 @@ class Translation(models.Model, URLMixin, LoggerMixin):
updated = False
for unit in self.unit_set.filter(pending=True).select_for_update():
# Skip changes by other authors
+ self.log_info('unit (%s)', unit)
+ self.log_info('unit.change_set.content() (%s)', unit.change_set.content())
+ unit_change = unit.change_set.content()
+ if not unit_change:
+ self.log_info('Empty change, skipping!')
+ unit.pending = False
+ unit.save(update_fields=['pending'], same_content=True)
+ continue
unit_change = unit.change_set.content().order_by('-timestamp')[0]
if unit_change.author_id != author_id:
continue
At least it allowed me to push the translations.
Thank you for your report, the issue you have reported has just been fixed.
Steps to reproduce
Unclear at this point. I guess perform a translation and commit it? Only one of our Projects/Components is affected, the others seem fine. Do note that we frequently have issues with duplicate resource keys in this component, since some of the resource files were inconsistent from the start (as in: English ResX has a key named "SubProjectName" while the German ResX has a key named "SubprojectName" because the dev entering it didn't pay attention. This frequently leads to Warnings in Visual Studio, which in turn removes one of them...and usually the wrong one. We fixed it a couple of times, but it keeps coming back). Check "Repository maintenance" and notice "There are some uncommitted changes!". Hit "Commit" and watch the error page send trained monkeys to fix it. Edit: It seems all Components of this Project show "There are some uncommitted changes!" while having clean working copies; other Projects seem to be fine.
Actual behaviour
Also: Hitting "Reset" appears to do something, but returns me back to a "Repository Maintenance" page that still says "There are some uncommitted changes!"
The Git working copy is clean, no uncommitted changes, no divergence from upstream.
Expected behaviour
Changes are committed.
Server configuration
Used caching backend is Redis. (Note that this is still on 2.20 after the previous attempt of upgrading to 3.0 left us with #2080; next maintenance window is coming up shortly though. Hoping this will make the current issue obsolete; but posting it anyways since I'm not sure if it will...)
I'm not too sure how to proceed from here; so any hints on what else I could try (or provide as info) here would help in debugging this.