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

DataError: ERROR: value too long for type character(200) #80

Open
habryk93 opened this issue Sep 22, 2017 · 2 comments
Open

DataError: ERROR: value too long for type character(200) #80

habryk93 opened this issue Sep 22, 2017 · 2 comments
Labels

Comments

@habryk93
Copy link

Error when send to long user-agent header

Expected Behavior

Status 200

Current Behavior

File "/python2.7/site-packages/django/core/handlers/base.py", line 199, in get_response
response = middleware_method(request, response)

File "/python2.7/site-packages/user_sessions/middleware.py", line 46, in process_response
request.session.save()

File "/python2.7/site-packages/user_sessions/backends/db.py", line 78, in save
obj.save(force_insert=must_create, using=using)

DataError: ERROR: value too long for type character(200)

Possible Solution

Should change Session model field user_agent from CharField to TextField
user_agent = models.CharField(null=True, blank=True, max_length=200)
to
user_agent = models.TextField(null=True, blank=True)
or
cropp user_agent field before save to db(but it can delete necessary information)
or
add max_length for exaple with 500 to TextField, but its not limit field in DB, only in django

Steps to Reproduce (for bugs)

  1. Add link to my page on facebook
  2. Go to link
  3. Facebook add some info to user_agent info
  4. Page return 500 (DataError: ERROR: value too long for type character)

Context

Your Environment

  • Browser and version: -
  • Python version: Python 2.7.12
  • Django version: Django==1.10.6
  • django-otp version: django-otp==0.3.11
  • django-user-sessions version: django-user-sessions==1.5.3
  • Link to your project: -
@Bouke
Copy link
Collaborator

Bouke commented Feb 14, 2018

What database backend are you using?

@Bouke Bouke added the bug label Feb 14, 2018
@habryk93
Copy link
Author

Postgres, but it is not problem with DB, you restrict your user_agent field to 200 symbols.
https://stackoverflow.com/questions/654921/how-big-can-a-user-agent-string-get

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants