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

django.db.utils.DataError: value too long for type character varying(200) #655

Closed
vmx opened this Issue Apr 11, 2019 · 5 comments

Comments

Projects
None yet
2 participants
@vmx
Copy link
Contributor

vmx commented Apr 11, 2019

Current Behavior

A talk cannot be accepted. My guess is that some field is too long (perhaps the title?).

ERROR 2019-04-11 07:11:42,845 django.request log Internal Server Error: /orga/event/REDACTED/submissions/REDACTED/accept
Traceback (most recent call last):
  File "/var/pretalx/venv/lib/python3.6/site-packages/django/db/backends/utils.py", line 85, in _execute
    return self.cursor.execute(sql, params)
psycopg2.DataError: value too long for type character varying(200)


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/var/pretalx/venv/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/var/pretalx/venv/lib/python3.6/site-packages/django/core/handlers/base.py", line 126, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/var/pretalx/venv/lib/python3.6/site-packages/django/core/handlers/base.py", line 124, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/var/pretalx/venv/lib/python3.6/site-packages/django/views/generic/base.py", line 68, in view
    return self.dispatch(request, *args, **kwargs)
  File "/var/pretalx/venv/lib/python3.6/site-packages/django/contrib/auth/mixins.py", line 85, in dispatch
    return super().dispatch(request, *args, **kwargs)
  File "/var/pretalx/venv/lib/python3.6/site-packages/django/views/generic/base.py", line 88, in dispatch
    return handler(request, *args, **kwargs)
  File "/usr/lib/python3.6/contextlib.py", line 52, in inner
    return func(*args, **kwds)
  File "/var/pretalx/venv/lib/python3.6/site-packages/pretalx/orga/views/submission.py", line 145, in post
    self.do()
  File "/var/pretalx/venv/lib/python3.6/site-packages/pretalx/orga/views/submission.py", line 123, in do
    method(person=self.request.user, force=force, orga=True)
  File "/var/pretalx/venv/lib/python3.6/site-packages/pretalx/submission/models/submission.py", line 317, in accept
    locale=self.content_locale,
  File "/var/pretalx/venv/lib/python3.6/site-packages/pretalx/mail/models.py", line 71, in to_mail
    mail.save()
  File "/var/pretalx/venv/lib/python3.6/site-packages/django/db/models/base.py", line 718, in save
    force_update=force_update, update_fields=update_fields)
  File "/var/pretalx/venv/lib/python3.6/site-packages/django/db/models/base.py", line 748, in save_base
    updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
  File "/var/pretalx/venv/lib/python3.6/site-packages/django/db/models/base.py", line 831, in _save_table
    result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
  File "/var/pretalx/venv/lib/python3.6/site-packages/django/db/models/base.py", line 869, in _do_insert
    using=using, raw=raw)
  File "/var/pretalx/venv/lib/python3.6/site-packages/django/db/models/manager.py", line 82, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/var/pretalx/venv/lib/python3.6/site-packages/django/db/models/query.py", line 1136, in _insert
    return query.get_compiler(using=using).execute_sql(return_id)
  File "/var/pretalx/venv/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 1289, in execute_sql
    cursor.execute(sql, params)
  File "/var/pretalx/venv/lib/python3.6/site-packages/django/db/backends/utils.py", line 68, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "/var/pretalx/venv/lib/python3.6/site-packages/django/db/backends/utils.py", line 77, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/var/pretalx/venv/lib/python3.6/site-packages/django/db/backends/utils.py", line 85, in _execute
    return self.cursor.execute(sql, params)
  File "/var/pretalx/venv/lib/python3.6/site-packages/django/db/utils.py", line 89, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/var/pretalx/venv/lib/python3.6/site-packages/django/db/backends/utils.py", line 85, in _execute
    return self.cursor.execute(sql, params)
django.db.utils.DataError: value too long for type character varying(200)

Expected Behavior

Talks can be accepted.

Steps to Reproduce

  1. Click on the accept button of that submission

Context

Not all talks can be accepted.

Your Environment

  • Version used: vmx@80cb5c4 which is a 6b82f13 + minor changes
  • Environment name and version (e.g. Chrome 39, python 3.5): Python 3.6.7
@vmx

This comment has been minimized.

Copy link
Contributor Author

vmx commented Apr 11, 2019

I found the problem (thanks to the traceback). The problem is that the subject in the email model is maximum 200 characters long:

subject = I18nCharField(

But the submission title can also have 200 characters: https://github.com/pretalx/pretalx/blob/master/src/pretalx/submission/models/submission.py#L99

This means that if you have a prefix in your subject of the acceptance mail (e.g. "Your submission:") and your submission title is 200 characters long, you will go beyond those 200 characters for the email subject.

One possible solution would be that the submission title is truncated so that the total length is always < 200 characters.

@vmx

This comment has been minimized.

Copy link
Contributor Author

vmx commented Apr 11, 2019

One quick fix would be to change

subject = str(self.subject).format(**context)

to something like subject = str(self.subject).format(**context)[:200], although that 200 probably shouldn't be hard-coded, but should come from the model definition.

@vmx

This comment has been minimized.

Copy link
Contributor Author

vmx commented Apr 14, 2019

I'm happy to work on a fix for that if I get told what a proper solution would look like.

@rixx

This comment has been minimized.

Copy link
Member

rixx commented Apr 15, 2019

Apologies, I was at a conference, so I didn't get around to this earlier.

@rixx rixx closed this in 17e7de0 Apr 15, 2019

@vmx

This comment has been minimized.

Copy link
Contributor Author

vmx commented Apr 15, 2019

Thanks a lot! That's exactly the fix I had it mind. No worries, I just thought it slipped your attention.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.