You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Cache write is failing when converting ASCII-8BIT characters to UTF-8 #38
I'm getting a Encoding::UndefinedConversionError exception when trying to cache GitHub responses. Some responses will be cached, but some will fail to write because of an encoding conversion issue.
changed the title [-]Cache write is failing when converting UTF-8 characters to ASCII-8BIT[/-][+]Cache write is failing when converting ASCII-8BIT characters to UTF-8[/+]on Apr 17, 2014
@salbertson thanks for the report. I'm not sure of how to fix this without messing up with the response, as the issue lies with net/http not handling encoding properly and JSON failing hard when converting the body to UTF-8, but it sucks to ship with broken defaults like that.
On your app you can swap the serializer to Yajl or Marshal and they should handle the serialization better.
In the mean time, a PR that emits a warning with the storage logger (instead of puts) will be very appreciated 😄.
Using Rails 4.2.0.rc3, warden-github, octokit and faraday-http-cache runs into a ASCII-8BIT to UTF-8 error. Its about the response body that holds a german "umlaut" like ü,ä or ö. As long as i use the faraday-http-cache middleware i get this error. Only way is to set Marshal as serializer instead of JSON. Didn't found any other solution for now.
Activity
[-]Cache write is failing when converting UTF-8 characters to ASCII-8BIT[/-][+]Cache write is failing when converting ASCII-8BIT characters to UTF-8[/+]lucasmazza commentedon Apr 17, 2014
@salbertson there is any public URL that is producing this error that we can use to debug it?
salbertson commentedon Apr 17, 2014
@lucasmazza here's one.
https://api.github.com/repos/thoughtbot/factory_girl_rails
salbertson commentedon Apr 17, 2014
I created a branch with a test to reproduce the issue. My first thought was to skip the write if the encoding fails.
salbertson/faraday-http-cache@master...sa-skip-write-when-encoding-errors
lucasmazza commentedon Apr 17, 2014
@salbertson thanks for the report. I'm not sure of how to fix this without messing up with the response, as the issue lies with
net/httpnot handling encoding properly andJSONfailing hard when converting the body toUTF-8, but it sucks to ship with broken defaults like that.On your app you can swap the serializer to
YajlorMarshaland they should handle the serialization better.In the mean time, a PR that emits a warning with the storage logger (instead of
puts) will be very appreciated 😄.salbertson commentedon Apr 17, 2014
@lucasmazza using
Marshalworked perfectly. Thanks, I'll get a pull request opened for the warning.monfresh commentedon Aug 22, 2014
I just ran into this as well, and I was able to get rid of the error by using
Marshalas the serializer, but now I'm getting this error for some URLs:Any idea what might be causing this and how to fix it?
Thanks!
skorth commentedon Dec 17, 2014
Using Rails 4.2.0.rc3, warden-github, octokit and faraday-http-cache runs into a ASCII-8BIT to UTF-8 error. Its about the response body that holds a german "umlaut" like ü,ä or ö. As long as i use the faraday-http-cache middleware i get this error. Only way is to set Marshal as serializer instead of JSON. Didn't found any other solution for now.
🎂 🐛 Use Marshal for Faraday serializer. Bump version. Fix #8.
Workaround for bug(?) in Net::HTTP.