Skip to content

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

Open

Description

@habryk93

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: -

Activity

  1. Bouke commented on Feb 14, 2018

    @Bouke
    Collaborator

    What database backend are you using?

  2. habryk93 commented on Jun 27, 2018

    @habryk93
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions