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

(fix+feat): If a language doesn't have a value for taxonomy set the default language value #172

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

dobri1408
Copy link

@dobri1408 dobri1408 commented Feb 20, 2025

We've identified a bug in the language translation of taxonomies. When a value is missing for a specific language, the system incorrectly assigns PATH_SEPARATOR + "" = id. This causes the taxonomy to default to a single value, matching the last term of the default language. Instead, if no value is provided for a given language, the correct behavior should be to use the default language value.

@dobri1408 dobri1408 changed the title (fix+feat): If a language doesn't have a value for taxonomy set the default language valit (fix+feat): If a language doesn't have a value for taxonomy set the default language value Feb 20, 2025
Comment on lines 144 to 146
data = json.loads(self.request.get("BODY", ""))
taxonomy = queryUtility(ITaxonomy, name=data["taxonomy"])
default_language = taxonomy.default_language
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code looks very brittle...

Imagine:

self.request.get("BODY", "")

evaluates to "".
Then you will have:

>>> json.loads("")
Traceback (most recent call last):
...
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

but every line that follow can easily fail if the request body is not exactly what you expect.

@dobri1408 dobri1408 requested a review from ale-rt February 23, 2025 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants