Closed Bug 1233540 Opened 9 years ago Closed 9 years ago

[commbadge] Traceback 'ascii' codec can't encode character u'\xf3' in position 87: ordinal not in range(128)

Categories

(Marketplace Graveyard :: Developer Pages, defect, P2)

Avenir
defect

Tracking

(Not tracked)

RESOLVED FIXED
2016-03-29

People

(Reporter: eviljeff, Assigned: ashort)

References

Details

(Whiteboard: [ktlo])

https://sentry.prod.mozaws.net/operations/zamboni-2/group/149590/ and other similar reports - its firing for me the thread; the app*; and /comm itself. *https://marketplace.firefox.com/app/smokingted/
The issue is that we are passing an unicode object for a filename to imghdr(), which uses low-level APIs so it expect (byte)strings. We should call .encode('utf-8') before using the path or use django storage API instead of open the file and pass a File instance to imghdr().
Stacktrace (most recent call last): File "rest_framework/views.py", line 400, in dispatch response = handler(request, *args, **kwargs) File "rest_framework/mixins.py", line 98, in list return Response(serializer.data) File "rest_framework/serializers.py", line 576, in data self._data = self.to_native(obj) File "rest_framework/serializers.py", line 355, in to_native value = field.field_to_native(obj, field_name) File "rest_framework/serializers.py", line 414, in field_to_native return [self.to_native(item) for item in value.all()] File "rest_framework/serializers.py", line 355, in to_native value = field.field_to_native(obj, field_name) File "rest_framework/serializers.py", line 414, in field_to_native return [self.to_native(item) for item in value.all()] File "rest_framework/serializers.py", line 355, in to_native value = field.field_to_native(obj, field_name) File "rest_framework/fields.py", line 337, in field_to_native return super(WritableField, self).field_to_native(obj, field_name) File "rest_framework/fields.py", line 208, in field_to_native value = get_component(value, component) File "rest_framework/fields.py", line 62, in get_component return val() File "mkt/comm/models.py", line 338, in is_image return imghdr.what(self.full_path()) is not None File "python2.7/imghdr.py", line 12, in what f = open(file, 'rb')
Assignee: nobody → kngo
Priority: -- → P2
Whiteboard: [ktlo]
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Assignee: kngo → ashort
Target Milestone: --- → 2016-02-09
Can you please give us some steps to reproduce or mark this bug as [qa-] if no qa is needed.
Try to attach a file with a non-ascii filename to a commbadge thread. If you can upload and then access the thread its fixed.
I managed to upload a file with unicode filename and the thread can still be opened. But when trying to download the attachment the file can't be found. Please view this screencast: http://screencast.com/t/taQxNm9Uor Reopening this bug.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
This seems to only be a problem for existing uploads not new ones, so no code fix is necessary. Reopen if there are old files we need to make accessible in production.
Status: REOPENED → RESOLVED
Closed: 9 years ago9 years ago
Resolution: --- → FIXED
Target Milestone: 2016-02-09 → 2016-03-29
(In reply to Allen Short [:ashort] from comment #8) > This seems to only be a problem for existing uploads not new ones, so no > code fix is necessary. Reopen if there are old files we need to make > accessible in production. We can't verify this in production. If someone can help with this and confirm it is ok in production I think we can close it.
You need to log in before you can comment on or make changes to this bug.