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

bug in saving short title when value is too long for page and section #1244

Closed
MyPyDavid opened this issue Feb 14, 2025 · 6 comments · Fixed by #1246 or #1250
Closed

bug in saving short title when value is too long for page and section #1244

MyPyDavid opened this issue Feb 14, 2025 · 6 comments · Fixed by #1246 or #1250

Comments

@MyPyDavid
Copy link
Member

Description / Beschreibung

 ERROR: Internal Server Error: /api/v1/questions/sections/
...
MySQLdb.DataError: (1406, "Data too long for column 'short_title_lang2' at row 1")
...
django.db.utils.DataError: (1406, "Data too long for column 'short_title_lang2' at row 1")

Expected behaviour / Erwartetes Verhalten

Saving a too long name for Short title shows an error eg. "given name is too long"

Could the max length value be passed to the front-end so that the JS can already validate the input while typing?

Steps to reproduce / Schritte zum Reproduzieren

  1. Go to /management/pages/1 or /management/sections/1
  2. add a long string for Short title
  3. click save
  4. See error

Context / Kontext

the RDMO 2.2.2 with MySQL.

Can not reproduce locally with sqlite.

References / Verweise

@MyPyDavid MyPyDavid added this to the RDMO 2.3.0 milestone Feb 14, 2025
@MyPyDavid MyPyDavid linked a pull request Feb 18, 2025 that will close this issue
@MyPyDavid MyPyDavid self-assigned this Feb 18, 2025
MyPyDavid added a commit that referenced this issue Feb 20, 2025
…itle-when-value-is-too-long-for-page-and-section

Add max length validation to translated fields.
Related issue: #1244
@MyPyDavid
Copy link
Member Author

MyPyDavid commented Feb 20, 2025

  • also for uri_path fields the Max Length validation is missing

@jochenklar
Copy link
Member

Ok, I think manually setting uri_path = serializers.CharField(required=True) in the serializer created the problem, because the usual validation is skipped. If you remove this line the lenght is correctly validated, but the field is not required anymore.

@jochenklar
Copy link
Member

It seems we need to use

        extra_kwargs = {
            'uri_path': {
                'required': True
            }
        }

in Meta instead of adding the field in the class. I can check all serializers tomorrow.

@jochenklar
Copy link
Member

There are maybe other fields affected.

@MyPyDavid
Copy link
Member Author

want to make this test parametrized for the different fields maybe?

def test_update_page_field_validation_short_title(db, client):

@jochenklar
Copy link
Member

I created #1250 for the issue. I don't think we need to add a test for this, since this would only test core Django/drf behavior. We (meaning I) learned how overriding serializer fields work.

@MyPyDavid MyPyDavid linked a pull request Feb 24, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment