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

Can't create thesauri in internationalized Arches 7.6.x #11794

Open
tris-ots opened this issue Feb 18, 2025 · 3 comments
Open

Can't create thesauri in internationalized Arches 7.6.x #11794

tris-ots opened this issue Feb 18, 2025 · 3 comments

Comments

@tris-ots
Copy link

I've experienced this issue on installs of Arches 7.6.0 and 7.6.6; after internationalizing Arches (in my case, French and English) I can't create thesauri in the Reference Data Manager.

Sometimes the newly created thesaurus appears in the list of thesauri, sometimes not. However, after this point, no thesauri can be created, viewed or edited. Clicking on any thesauri that appear in the list displays a "Loading..." message in the righthand pane, apparently forever. As far as I can tell, all the above is true for whatever language the RDM is used in (in my case, either https://domainname/en/rdm or https://domainname/fr-fr/rdm).

@apeters kindly suggested that creating a Thesaurus Service Provider with the fr-fr language might fix the issue, but unfortunately this didn't work in my case, on either 7.6.0 or 7.6.6.

Steps to reproduce:

  • Internationalize Arches per documentation.
  • Run python manage.py graph publish --update
  • Restart Arches.
  • Attempt to create a thesaurus in the RDM.

Expected behavior:

  • It should be possible to create and modify thesauri as usual in an internationalized Arches.

Digging into the system logs, I found that Arches output variations on this message while I was trying to work with the RDM:

Internal Server Error: /en/concepts/ed479805-6af7-4bb4-b133-a7abdb5b43a5
Traceback (most recent call last):
  File "/opt/arches/.venv/lib/python3.11/site-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
               ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/arches/.venv/lib/python3.11/site-packages/django/core/handlers/base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/arches/.venv/lib/python3.11/site-packages/django/contrib/auth/decorators.py", line 23, in _wrapper_view
    return view_func(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/arches/arches_source/arches/app/views/concept.py", line 233, in concept
    "sparql_providers": get_sparql_providers(),
                        ^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/arches/arches_source/arches/app/views/concept.py", line 102, in get_sparql_providers
    provider_class = provider["SPARQL_ENDPOINT_PROVIDER"][settings.LANGUAGE_CODE][
                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
KeyError: 'fr-fr'

The messages had different concept UUIDs (I guess since I was trying to create or interact with multiple thesauri) but always referred to a KeyError and to a problem with the get_sparql_providers function. Obviously this supports Alexei's thought that there's some issue with the SPARQL endpoint.

While I was trying to apply Alexei's suggested fix, I also encountered the bug I described in #11793.

@apeters
Copy link
Member

apeters commented Feb 19, 2025

Hi @tris-ots ,
I'm inferring from the stack trace that your LANGUAGE_CODE setting in settings.py is set to fr-fr. Have you tried setting that back to en. I would try that to see if it fixes the issue.

Also can you confirm that you have a language in your languages table that corresponds to fr-fr. You can check this by going to the admin page and looking at the languages model (http://localhost:8000/en/admin/models/language/). If you don't have that language there, you should add it. You'll then need to apply my previous suggestion about adding a Thesaurus Service Provider with the fr-fr language.
Good luck!

@tris-ots
Copy link
Author

tris-ots commented Feb 19, 2025

hi @apeters and thanks so much for all your help with this problem.
You're correct that my LANGUAGE_CODE is fr-fr, and English and French are listed in the Django admin page. I did apply your suggested fix of creating an fr-fr Thesaurus Service Provider, but without success - the same message appeared in the system logs.

However, when i set the LANGUAGE_CODE back to en, things seem to start working again - if anyone encounters this issue in the future, that seems to be the fix, at least for now.

At one point I got this error which suggested that the language code should be fr-FRas Jacob Walls mentioned:

Internal Server Error: /en/concepts/
Traceback (most recent call last):
  File "/opt/arches/.venv/lib/python3.11/site-packages/django/db/backends/base/base.py", line 313, in _commit
    return self.connection.commit()
           ^^^^^^^^^^^^^^^^^^^^^^^^
psycopg2.errors.ForeignKeyViolation: insert or update on table "values" violates foreign key constraint "values_languageid_14bf08a2_fk_languages_code"
DETAIL:  Key (languageid)=(fr-FR) is not present in table "languages".
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "/opt/arches/.venv/lib/python3.11/site-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
               ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/arches/.venv/lib/python3.11/site-packages/django/core/handlers/base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/arches/.venv/lib/python3.11/site-packages/django/contrib/auth/decorators.py", line 23, in _wrapper_view
    return view_func(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/arches/arches_source/arches/app/views/concept.py", line 312, in concept
    with transaction.atomic():
  File "/opt/arches/.venv/lib/python3.11/site-packages/django/db/transaction.py", line 263, in __exit__
    connection.commit()
  File "/opt/arches/.venv/lib/python3.11/site-packages/django/utils/asyncio.py", line 26, in inner
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/arches/.venv/lib/python3.11/site-packages/django/db/backends/base/base.py", line 337, in commit
    self._commit()
  File "/opt/arches/.venv/lib/python3.11/site-packages/django/db/backends/base/base.py", line 312, in _commit
    with debug_transaction(self, "COMMIT"), self.wrap_database_errors:
  File "/opt/arches/.venv/lib/python3.11/site-packages/django/db/utils.py", line 91, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/opt/arches/.venv/lib/python3.11/site-packages/django/db/backends/base/base.py", line 313, in _commit
    return self.connection.commit()
           ^^^^^^^^^^^^^^^^^^^^^^^^
django.db.utils.IntegrityError: insert or update on table "values" violates foreign key constraint "values_languageid_14bf08a2_fk_languages_code"
DETAIL:  Key (languageid)=(fr-FR) is not present in table "languages".

However, when I set both the values in LANGUAGES and LANGUAGE_CODE to fr-FR, I still got the same KeyError in provider["SPARQL_ENDPOINT_PROVIDER"][settings.LANGUAGE_CODE] as originally. I did run django-admin makemessages -l fr_FR and compilemessages, and restart Arches, after making this change.

@kfogel
Copy link
Contributor

kfogel commented Feb 20, 2025

@tris-ots FWIW I'm confident we're going to solve this (with thanks to @apeters for the help)! I'd just like to make sure that once we have solved it, we then submit whatever documentation updates are appropriate, so that future localizers have an easier time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

3 participants