denverfoundation / storybase

The code behind Floodlight
http://floodlightproject.org
MIT License
11 stars 7 forks source link

Internal Server Error on POST to /api/0.1/locations/stories/STORY_ID/ #496

Closed ghing closed 11 years ago

ghing commented 11 years ago

Seeing a lot of error messages for this.

Traceback (most recent call last):

      File "/home/floodlight/webapps/floodlight_production/venv/lib/python2.7/site-packages/tastypie/resources.py", line 202, in wrapper
        response = callback(request, *args, **kwargs)

      File "/home/floodlight/webapps/floodlight_production/venv/lib/python2.7/site-packages/tastypie/resources.py", line 441, in dispatch_list
        return self.dispatch('list', request, **kwargs)

      File "/home/floodlight/webapps/floodlight_production/floodlight/apps/storybase/api/resources.py", line 344, in dispatch
        response = method(request, **kwargs)

      File "/home/floodlight/webapps/floodlight_production/venv/lib/python2.7/site-packages/tastypie/resources.py", line 1258, in post_list
        updated_bundle = self.obj_create(bundle, request=request, **self.remove_api_resource_names(kwargs))

      File "/home/floodlight/webapps/floodlight_production/floodlight/apps/storybase_geo/api.py", line 84, in obj_create
        bundle, request, **kwargs)

      File "/home/floodlight/webapps/floodlight_production/floodlight/apps/storybase/api/resources.py", line 137, in obj_create
        bundle.obj.save()

      File "/home/floodlight/webapps/floodlight_production/venv/lib/python2.7/site-packages/django/db/models/base.py", line 460, in save
        self.save_base(using=using, force_insert=force_insert, force_update=force_update)

      File "/home/floodlight/webapps/floodlight_production/venv/lib/python2.7/site-packages/django/db/models/base.py", line 553, in save_base
        result = manager._insert(values, return_id=update_pk, using=using)

      File "/home/floodlight/webapps/floodlight_production/venv/lib/python2.7/site-packages/django/db/models/manager.py", line 195, in _insert
        return insert_query(self.model, values, **kwargs)

      File "/home/floodlight/webapps/floodlight_production/venv/lib/python2.7/site-packages/django/db/models/query.py", line 1436, in insert_query
        return query.get_compiler(using=using).execute_sql(return_id)

      File "/home/floodlight/webapps/floodlight_production/venv/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 791, in execute_sql
        cursor = super(SQLInsertCompiler, self).execute_sql(None)

      File "/home/floodlight/webapps/floodlight_production/venv/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 735, in execute_sql
        cursor.execute(sql, params)

      File "/home/floodlight/webapps/floodlight_production/venv/lib/python2.7/site-packages/django/db/backends/postgresql_psycopg2/base.py", line 44, in execute
        return self.cursor.execute(query, args)

    DatabaseError: invalid byte sequence for encoding "UTF8": 0x00

    <WSGIRequest
    GET:<QueryDict: {}>,
    POST:<QueryDict: {u'{"name":"","lat":39.747051,"lng":-104.996703,"raw":"1515 Arapahoe St, Denver, CO  80202-2117, United States, Denver, United States"}': [u'']}>,
    COOKIES:{'__atuvc': '1%7C48',
     '__utma': '172805236.1359533231.1354296485.1354296485.1354296485.1',
     '__utmb': '172805236.3.10.1354296485',
     '__utmc': '172805236',
     '__utmz': '172805236.1354296485.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)',
     'csrftoken': 'af81650ddfa679fb596a093511143856',
     'django_language': 'en',
     'sessionid': '99d455f64d759da670c2c0f7cf009290',
     'storybase_show_builder_tour': 'false'},
    META:{'CONTENT_LENGTH': '132',
     'CONTENT_TYPE': 'application/json',
     'CSRF_COOKIE': 'af81650ddfa679fb596a093511143856',
     'DOCUMENT_ROOT': '/usr/local/apache2/htdocs',
     'GATEWAY_INTERFACE': 'CGI/1.1',
     'HTTP_ACCEPT': 'application/json, text/javascript, */*; q=0.01',
     'HTTP_ACCEPT_CHARSET': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3',
     'HTTP_ACCEPT_ENCODING': 'gzip,deflate,sdch',
     'HTTP_ACCEPT_LANGUAGE': 'en-US,en;q=0.8',
     'HTTP_CONNECTION': 'close',
     'HTTP_COOKIE': 'csrftoken=af81650ddfa679fb596a093511143856; __utma=172805236.1359533231.1354296485.1354296485.1354296485.1; __utmb=172805236.3.10.1354296485; __utmc=172805236; __utmz=172805236.1354296485.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); sessionid=99d455f64d759da670c2c0f7cf009290; __atuvc=1%7C48; storybase_show_builder_tour=false; django_language=en',
     'HTTP_FORWARDED_REQUEST_URI': '/api/0.1/locations/stories/db4a6f037958441a9e30095cc1c1831d/',
     'HTTP_HOST': 'floodlightproject.org',
     'HTTP_HTTPS': 'off',
     'HTTP_HTTP_X_FORWARDED_PROTO': 'http',
     'HTTP_ORIGIN': 'http://floodlightproject.org',
     'HTTP_REFERER': 'http://floodlightproject.org/en/build/db4a6f037958441a9e30095cc1c1831d/tag/',
     'HTTP_USER_AGENT': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.95 Safari/537.11',
     'HTTP_X_FORWARDED_FOR': '174.29.155.235',
     'HTTP_X_FORWARDED_HOST': 'floodlightproject.org',
     'HTTP_X_FORWARDED_PROTO': 'http',
     'HTTP_X_FORWARDED_SERVER': 'floodlightproject.org',
     'HTTP_X_FORWARDED_SSL': 'off',
     'HTTP_X_REQUESTED_WITH': 'XMLHttpRequest',
     'PATH_INFO': u'/api/0.1/locations/stories/db4a6f037958441a9e30095cc1c1831d/',
     'PATH_TRANSLATED': '/home/floodlight/webapps/floodlight_production/floodlight/wsgi.py/api/0.1/locations/stories/db4a6f037958441a9e30095cc1c1831d/',
     'QUERY_STRING': '',
     'REMOTE_ADDR': '127.0.0.1',
     'REMOTE_PORT': '49952',
     'REQUEST_METHOD': 'POST',
     'REQUEST_URI': '/api/0.1/locations/stories/db4a6f037958441a9e30095cc1c1831d/',
     'SCRIPT_FILENAME': '/home/floodlight/webapps/floodlight_production/floodlight/wsgi.py',
     'SCRIPT_NAME': u'',
     'SERVER_ADDR': '127.0.0.1',
     'SERVER_ADMIN': '[no address given]',
     'SERVER_NAME': 'floodlightproject.org',
     'SERVER_PORT': '80',
     'SERVER_PROTOCOL': 'HTTP/1.0',
     'SERVER_SIGNATURE': '',
     'SERVER_SOFTWARE': 'Apache/2.2.17 (Unix) mod_wsgi/3.4 Python/2.7.3',
     'mod_wsgi.application_group': 'dweb160.webfaction.com|',
     'mod_wsgi.callable_object': 'application',
     'mod_wsgi.enable_sendfile': '0',
     'mod_wsgi.handler_script': '',
     'mod_wsgi.input_chunked': '0',
     'mod_wsgi.listener_host': '',
     'mod_wsgi.listener_port': '30266',
     'mod_wsgi.process_group': 'floodlight_production',
     'mod_wsgi.queue_start': '1354296528849470',
     'mod_wsgi.request_handler': 'wsgi-script',
     'mod_wsgi.script_reloading': '1',
     'mod_wsgi.version': (3, 4),
     'wsgi.errors': <mod_wsgi.Log object at 0x7f72cac92130>,
     'wsgi.file_wrapper': <built-in method file_wrapper of mod_wsgi.Adapter object at 0x7f72cad5ba80>,
     'wsgi.input': <mod_wsgi.Input object at 0x7f72c91cdb70>,
     'wsgi.multiprocess': True,
     'wsgi.multithread': False,
     'wsgi.run_once': False,
     'wsgi.url_scheme': 'http',
     'wsgi.version': (1, 0)}>
ghing commented 11 years ago

It looks like this is because of the issues described at http://stackoverflow.com/questions/7667724/error-saving-geodjango-pointfield

There's a patch at https://code.djangoproject.com/ticket/16778 and I included it in https://github.com/PitonFoundation/atlas/blob/develop/patches/postgis-adapter-2.patch, but it looks like I may not have applied this patch to the production Django. This shouldn't be an issue when we upgrade to Django 1.4.

ghing commented 11 years ago

I patched the production Django instance. Closing.