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

When creating a new term, if the key is a child of another key that has assigned a value, clear cache gives a 500 server error #76

Open
martanducas opened this issue Oct 6, 2021 · 2 comments

Comments

@martanducas
Copy link

martanducas commented Oct 6, 2021

This issue has been updated, the real problem is as follows:

I have added some new terms with the following keys:
custom.pae.services
custom.pae.services.1
custom.pae.services.2

I have cleared cache.
The server has crashed (error 500 Internal server error).

@microstudi (https://github.com/microstudi) can give more technical details, but the problem is that according to the YAML format, a key (custom.pae.services) cannot have assigned a value if it has child keys (custom.pae.services.1). Since a user like me is not aware of this restriction, it is necessary to have some kind of validation that avoids this behaviour (otherwise, any admin user can crash a Decidim by adding new terms).

@microstudi
Copy link

microstudi commented Oct 6, 2021

Yep, also updating this comment:

Hi, the error appears in this line:

It is thrown in the first view rendered, with this message:

ActionView::Template::Error (no implicit conversion of Symbol into Integer)

The problem is that TermCustomizer accepts any string as a key for a translations, without checking if it would be a valid structure if it'd come from a YAML file.

As @marta-platoniq said, you can add these keys in term customizer:

custom.pae.services: something
custom.pae.services.1: another text
custom.pae.services.2: yet another text

Which would correspond to this YAML structure:

custom:
  pae:
    services: Something
      1: another text
      2: yet another text

Which is invalid.

Probably a solution would involve creating an extra validator in the form handleing the controller request to check if all the keys are compatible.

@martanducas martanducas changed the title When creating a new term, if the literal includes a number, clear cache gives a 500 server error When creating a new term, if the key is a child of another key that has a literal, clear cache gives a 500 server error Oct 6, 2021
@martanducas martanducas changed the title When creating a new term, if the key is a child of another key that has a literal, clear cache gives a 500 server error When creating a new term, if the key is a child of another key that has assigned a value, clear cache gives a 500 server error Oct 6, 2021
@ahukkanen
Copy link
Collaborator

Yep, this is a known issue.

The problem is that if solved properly, it's quite difficult. I think the best solution to this would be to provide the translation interface for these special translation cases, such as lists or zero/one/other or odd/even type of strings. So instead of adding them separately, you could define different types of translations, such as list translation, which would be then customized according to that specified structure.

And how would that apply to the dynamic translation adding. I believe there would need to be some changes there as well to detect the type for each of the imported strings.

I haven't checked myself how many of these different type situations there are.

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

No branches or pull requests

3 participants