ceys / django-tracking

Automatically exported from code.google.com/p/django-tracking
MIT License
0 stars 0 forks source link

Should not bomb on long URLs and long User-Agent strings #15

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Requesting a URL longer than 255 chars (!) causes this exception, killing the 
request:

Traceback (most recent call last):
  File "/var/www-live/datamarket/apache/django.wsgi", line 25, in application
    return _application(environ, start_response)
  File "/var/pythonenv/LIVE/lib/python2.5/site-packages/django/core/handlers/wsgi.py", line 
241, in __call__
    response = self.get_response(request)
  File "/var/pythonenv/LIVE/lib/python2.5/site-packages/django/core/handlers/base.py", line 
73, in get_response
    response = middleware_method(request)
  File "/var/pythonenv/LIVE/lib/python2.5/site-packages/tracking/middleware.py", line 114, in 
process_request
    visitor.save()
  File "/var/pythonenv/LIVE/lib/python2.5/site-packages/django/db/models/base.py", line 410, 
in save
    self.save_base(force_insert=force_insert, force_update=force_update)
  File "/var/pythonenv/LIVE/lib/python2.5/site-packages/django/db/models/base.py", line 474, 
in save_base
    rows = manager.filter(pk=pk_val)._update(values)
  File "/var/pythonenv/LIVE/lib/python2.5/site-packages/django/db/models/query.py", line 444, 
in _update
    return query.execute_sql(None)
  File "/var/pythonenv/LIVE/lib/python2.5/site-packages/django/db/models/sql/subqueries.py", 
line 120, in execute_sql
    cursor = super(UpdateQuery, self).execute_sql(result_type)
  File "/var/pythonenv/LIVE/lib/python2.5/site-packages/django/db/models/sql/query.py", line 
2369, in execute_sql
    cursor.execute(sql, params)
DataError: value too long for type character varying(255)

I can change the column type (255 was the default that django_tracking set up), 
but a tracking 
middleware really should not be killing requests in a case like this. It should 
truncate the URL to 
the maximum width and log a warning.

The same seems to happen on very long User-Agent strings (from Microsoft 
browsers that inform 
about all the versions of the .Net framework installed, InfoPath and so on) — 
at least I'm getting 
errors in the log to that effect.

Original issue reported on code.google.com by gunnlau...@gmail.com on 4 May 2010 at 2:37

GoogleCodeExporter commented 8 years ago
This seems to have been addressed in [9b72f9bb6d36], is that fix considered 
finished? Can anyone reproduce 
this?

Original comment by gunnlau...@gmail.com on 12 May 2010 at 11:54

GoogleCodeExporter commented 8 years ago
Yes, gunnlaugur seems to be correct.  This has been resolved since April 15, 
2009.

Original comment by wheaties...@gmail.com on 27 Dec 2010 at 5:11