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

Silk fails on binary staticfiles content #16

Closed
peterbe opened this issue Jun 12, 2014 · 4 comments
Closed

Silk fails on binary staticfiles content #16

peterbe opened this issue Jun 12, 2014 · 4 comments

Comments

@peterbe
Copy link
Contributor

peterbe commented Jun 12, 2014

When I'm in production mode I'll let Nginx go straight to the filesystem on these things but when in debug mode I add this to my root urls.py:

if settings.DEBUG:
    urlpatterns += patterns('', url(r'^silk', include('silk.urls', namespace='silk')))
    urlpatterns += static(
        settings.MEDIA_URL,
        document_root=settings.MEDIA_ROOT
    )

Any request on something going through /cache/foo/bar.jpg will cause this traceback.

Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/wsgiref/handlers.py", line 85, in run
    self.result = application(self.environ, self.start_response)
  File "/Users/peterbe/virtualenvs/dailycookie/lib/python2.7/site-packages/django/contrib/staticfiles/handlers.py", line 67, in __call__
    return self.application(environ, start_response)
  File "/Users/peterbe/virtualenvs/dailycookie/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 206, in __call__
    response = self.get_response(request)
  File "/Users/peterbe/virtualenvs/dailycookie/lib/python2.7/site-packages/django/core/handlers/base.py", line 205, in get_response
    response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
  File "/Users/peterbe/virtualenvs/dailycookie/lib/python2.7/site-packages/django/core/handlers/base.py", line 201, in get_response
    response = middleware_method(request, response)
  File "/Users/peterbe/virtualenvs/dailycookie/lib/python2.7/site-packages/silk/middleware.py", line 183, in process_response
    silky_response.save()
  File "/Users/peterbe/virtualenvs/dailycookie/lib/python2.7/site-packages/django/db/models/base.py", line 545, in save
    force_update=force_update, update_fields=update_fields)
  File "/Users/peterbe/virtualenvs/dailycookie/lib/python2.7/site-packages/django/db/models/base.py", line 573, in save_base
    updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
  File "/Users/peterbe/virtualenvs/dailycookie/lib/python2.7/site-packages/django/db/models/base.py", line 635, in _save_table
    forced_update)
  File "/Users/peterbe/virtualenvs/dailycookie/lib/python2.7/site-packages/django/db/models/base.py", line 679, in _do_update
    return filtered._update(values) > 0
  File "/Users/peterbe/virtualenvs/dailycookie/lib/python2.7/site-packages/django/db/models/query.py", line 507, in _update
    return query.get_compiler(self.db).execute_sql(None)
  File "/Users/peterbe/virtualenvs/dailycookie/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 975, in execute_sql
    cursor = super(SQLUpdateCompiler, self).execute_sql(result_type)
  File "/Users/peterbe/virtualenvs/dailycookie/lib/python2.7/site-packages/silk/sql.py", line 49, in execute_sql
    return self._execute_sql(*args, **kwargs)
  File "/Users/peterbe/virtualenvs/dailycookie/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 781, in execute_sql
    cursor.execute(sql, params)
  File "/Users/peterbe/virtualenvs/dailycookie/lib/python2.7/site-packages/django/db/backends/util.py", line 73, in execute
    sql = self.db.ops.last_executed_query(self.cursor, sql, params)
  File "/Users/peterbe/virtualenvs/dailycookie/lib/python2.7/site-packages/django/db/backends/postgresql_psycopg2/operations.py", line 214, in last_executed_query
    return cursor.query.decode('utf-8')
  File "/Users/peterbe/virtualenvs/dailycookie/lib/python2.7/encodings/utf_8.py", line 16, in decode
    return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xff in position 82: invalid start byte
mtford90 added a commit that referenced this issue Jun 12, 2014
@mtford90
Copy link
Collaborator

Oops, thought I'd fixed this!

That line of code currently tries to catch DjangoUnicodeDecodeError to deal with this issue, which is a descendent of UnicodeDecodeError.

I just pushed a fix for this. If you upgrade via pypi this issue should be resolved. Note changes to the models were made for 0.2 so you'll need to delete&sync/migrate.

Cheers

@mtford90
Copy link
Collaborator

Was this issue solved in the end?

@peterbe
Copy link
Contributor Author

peterbe commented Jun 17, 2014

I haven't tried out the new version yet. When I got stuck I just corrected my setup to serve these files directly from nginx locally.

@mtford90
Copy link
Collaborator

mtford90 commented Jul 5, 2014

Tested this pretty thoroughly so gonna close. Let me know if any further issues

@mtford90 mtford90 closed this as completed Jul 5, 2014
pablodiazgutierrez pushed a commit to appfluence/django-silk that referenced this issue Oct 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants