DjangoGirls / djangogirls

Website for DjangoGirls.org
http://djangogirls.org/
BSD 3-Clause "New" or "Revised" License
462 stars 283 forks source link

DataError: value too long for type character varying(30) #921

Closed sentry-io[bot] closed 8 months ago

sentry-io[bot] commented 10 months ago

Sentry Issue: DJANGO-GIRLS-WEBSITE-60

StringDataRightTruncation: value too long for type character varying(30)

  File "django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)

DataError: value too long for type character varying(30)

(20 additional frame(s) were not displayed)
...
  File "organize/views.py", line 50, in done
    application = EventApplication.object.create(**data_dict)
  File "organize/models.py", line 75, in create
    return super().create(**data_dict)
  File "organize/models.py", line 146, in save
    super().save(*args, **kwargs)
dostogircse171 commented 9 months ago

Hi, I noticed this issue reported by the bot and would like to work on resolving it. If there are any specific guidelines or additional information needed before I begin, please let me know.

amakarudze commented 8 months ago

Hello @dostogircse171. Thank you for your interest in solving this issue.

The screenshots below are from Sentry, to show the stack trace better.

Screenshot 2023-12-31 at 04 16 27 Screenshot 2023-12-31 at 04 17 15

latlng is defined with a max_length=30 here https://github.com/DjangoGirls/djangogirls/blob/main/organize/models.py#L84C1-L88 but when latlng is being generated here by the get_coordinates_for_city() function here https://github.com/DjangoGirls/djangogirls/blob/main/organize/models.py#L144, the result is sometimes longer than 30 characters hence the data error while trying to save the event.

dostogircse171 commented 8 months ago

@amakarudze Thank you very much for providing more clear instructions. I will make these changes and do a PR when done so you can review them.

One question for you. Is it ok to increase the chars limit from model class or I should handle it from save() method by limiting chars to 30 in self.latlng instance of EventApplication class