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

KeyError when attempting to upload an translation file #4245

Closed
superDross opened this issue Aug 3, 2020 · 3 comments
Closed

KeyError when attempting to upload an translation file #4245

superDross opened this issue Aug 3, 2020 · 3 comments
Assignees
Labels
bug Something is broken.
Milestone

Comments

@superDross
Copy link
Contributor

Describe the bug

When trying to upload a PO file to overwrite existing translations I am met with an KeyError referring to author_name.

I suspect this is because the upload file form should have an author name and author email field but does not.

To Reproduce

Steps to reproduce the behavior:

Via the admin interface:

  • Create a role with every single permission
  • Create a permission group with newly created role
  • Assign group to desired user

Via the Weblate instance:

  • Go to the upload translation file as described here
  • Uploading a file and picking any option will trigger it but I am interested in Replace exisintg translation file and Import as translated
  • Press the Upload button

Expected behavior

A message telling me the outcome of uploading the translation file.

Server configuration and status

  • Weblate: 4.1.1
  • Django: 3.0.8
  • siphashc: 1.3
  • Whoosh: 2.7.4
  • translate-toolkit: 3.0.0
  • lxml: 4.5.1
  • Pillow: 7.1.2
  • bleach: 3.1.5
  • python-dateutil: 2.8.1
  • social-auth-core: 3.3.3
  • social-auth-app-django: 3.4.0
  • django-crispy-forms: 1.9.1
  • oauthlib: 3.1.0
  • django-compressor: 2.4
  • djangorestframework: 3.11.0
  • django-filter: 2.3.0
  • django-appconf: 1.0.4
  • user-agents: 2.1
  • filelock: 3.0.12
  • setuptools: 40.8.0
  • jellyfish: 0.8.2
  • openpyxl: 3.0.1
  • celery: 4.4.6
  • kombu: 4.6.11
  • translation-finder: 2.1
  • html2text: 2020.1.16
  • pycairo: 1.16.2
  • pygobject: 3.30.4
  • diff-match-patch: 20181111
  • requests: 2.24.0
  • django-redis: 4.12.1
  • hiredis: 1.0.1
  • sentry_sdk: 0.15.1
  • Cython: 0.29.20
  • misaka: 2.1.1
  • GitPython: 3.1.3
  • borgbackup: 1.1.13
  • pyparsing: 2.4.7
  • Python: 3.7.3
  • Git: 2.20.1
  • psycopg2: 2.8.5
  • psycopg2-binary: 2.8.5
  • phply: 1.2.5
  • chardet: 3.0.4
  • ruamel.yaml: 0.16.10
  • tesserocr: 2.5.1
  • akismet: 1.1
  • boto3: 1.14.14
  • zeep: 3.4.0
  • aeidon: 1.7.0
  • iniparse: 0.5
  • mysqlclient: 1.4.6
  • Mercurial: 5.4.2
  • git-svn: 2.20.1
  • git-review: 1.28.0
  • hub: 2.13.0
  • lab: 0.16
  • Redis server: 5.0.9
  • PostgreSQL server: 11.8
  • Database backends: django.db.backends.postgresql
  • Cache backends: default:RedisCache, avatar:FileBasedCache
  • Email setup: django.core.mail.backends.smtp.EmailBackend: smtp.mailtrap.io
  • OS encoding: filesystem=utf-8, default=utf-8
  • Celery: redis://cache:6379/1, redis://cache:6379/1, regular
  • Platform: Linux 5.4.52-1-MANJARO (x86_64)

Exception traceback

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.7/dist-packages/django/core/handlers/base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/usr/local/lib/python3.7/dist-packages/django/core/handlers/base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_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/files.py", line 146, in upload_translation
    author_name = form.cleaned_data["author_name"]

Exception Type: KeyError at /upload/bilingual-vs-monolingual/monolingual/aa/
Exception Value: 'author_name'

Screen Shot
thiingy

As can be seen in the above screen shot, no author name or author email fields are present as one would expect.

Additional context

This works fine when you add the <component-name>@Administration group to the users chosen groups via the admin interface. The difference being the Author name and email fields are available in the upload translation form.

nijel added a commit that referenced this issue Aug 3, 2020
We need to evaluate component level permissions as well.

Issue #4245
@nijel
Copy link
Member

nijel commented Aug 3, 2020

Any component level permission in place here? In case it is, it will be most likely fixed by ab0a6a1.

@nijel nijel self-assigned this Aug 3, 2020
@nijel nijel added the bug Something is broken. label Aug 3, 2020
@nijel nijel added this to the 4.2 milestone Aug 3, 2020
@superDross
Copy link
Contributor Author

Yeah there is. Once I deselect all components from the permissions group I can see the author name and author email fields available in the upload translation form.

Thanks for the speedy reply.

@nijel nijel closed this as completed Aug 3, 2020
@github-actions
Copy link

github-actions bot commented Aug 3, 2020

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, consider supporting Weblate by donating.

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

2 participants