UnicodeEncodeError in unquoting the path
- Dominant language
- Python
- Stars
- 4.4k
- Forks
- 437
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 15
Description
https://sentry.prod.mozaws.net/operations/kinto-webextensions-prod/issues/4723172/?query=is:unresolved
```
UnicodeEncodeError: 'ascii' codec can't encode characters in position 144-147: ordinal not in range(128)
File "pyramid/tweens.py", line 39, in excview_tween
response = handler(request)
File "kinto/core/events.py", line 76, in tween
response = handler(request)
File "pyramid/router.py", line 156, in handle_request
view_name
File "pyramid/view.py", line 642, in _call_view
response = view_callable(context, request)
File "pyramid/config/views.py", line 181, in __call__
return view(context, request)
File "pyramid/viewderivers.py", line 390, in attr_view
return view(context, request)
File "pyramid/viewderivers.py", line 368, in predicate_wrapper
return view(context, request)
File "pyramid/viewderivers.py", line 439, in rendered_view
result = view(context, request)
File "pyramid/viewderivers.py", line 148, in _requestonly_view
response = view(request)
File "cornice/service.py", line 502, in wrapper
response = view_(request)
File "kinto/core/views/batch.py", line 139, in post_batch
subrequest = build_request(request, subrequest_spec)
File "kinto/core/utils.py", line 370, in build_request
method=method)
File "webob/request.py", line 1346, in blank
env = environ_from_url(path)
File "webob/request.py", line 1443, in environ_from_url
path_info = url_unquote(path)
File "webob/compat.py", line 103, in url_unquote
return unquote(s.encode('ascii')).decode('latin-1')
```
According to Sentry the `s` variable is `'/v1/buckets/default/collections/ext-8f641XJPcYKMevbo_IHSjtztGey341gtEiw9ABlao6s/records/id-1yESnI5FCxK_U2TXXzeuYA7bl-sOkttf-9Kcs2yHa-c7hdfrm4fw0ÃÂepzt2lrn49'`
Contributor guide
Research direction
Start in kinto/core/utils.py around build_request, then read WebOb's webob/request.py and webob/compat.py around environ_from_url and url_unquote. Reproduce the batch request with the reported non-ASCII path and determine the expected unquoting behavior. Done means the request no longer raises UnicodeEncodeError and the behavior is covered by an appropriate test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100