# rails 3.0.9 ArgumentError (redundant UTF-8 sequence):

**URL:** <https://discuss.rubyonrails.org/t/rails-3-0-9-argumenterror-redundant-utf-8-sequence/59856>\
**Category:** rubyonrails-talk\
**Created:** [July 14, 2011, 8:47am UTC](https://discuss.rubyonrails.org/t/rails-3-0-9-argumenterror-redundant-utf-8-sequence/59856 "2011-07-14T08:47:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![11155](https://avatars.discourse-cdn.com/v4/letter/1/d26b3c/32.png) [@11155](https://discuss.rubyonrails.org/u/11155)\
**Post date:** [July 14, 2011, 8:47am UTC](https://discuss.rubyonrails.org/t/rails-3-0-9-argumenterror-redundant-utf-8-sequence/59856/1 "2011-07-14T08:47:15Z")

</div>

Hi guys, I have a simple controller

&nbsp;&nbsp;def gmap &nbsp;&nbsp;&nbsp;&nbsp;@intentsearches = Intentsearch.all &nbsp;&nbsp;&nbsp;&nbsp;logger.info @intentsearches &nbsp;&nbsp;&nbsp;&nbsp;respond\_to do |format| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;format.html {render :gmap} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;format.xml {render :xml =\> @intentsearches } &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;format.json { render :json =\> @intentsearches } &nbsp;&nbsp;&nbsp;&nbsp;end &nbsp;&nbsp;end

and want a json response, but i do get the following error

Completed 500 Internal Server Error in 107ms

ArgumentError (redundant UTF-8 sequence): &nbsp;&nbsp;app/controllers/intentsearches\_controller.rb:103:in `gmap' &nbsp;&nbsp;app/controllers/intentsearches_controller.rb:100:in `gmap'

Rendered /usr/lib/ruby/gems/1.8/gems/actionpack-3.0.9/lib/action\_dispatch/middleware/templates/rescues/\_trace.erb (1.0ms) Rendered /usr/lib/ruby/gems/1.8/gems/actionpack-3.0.9/lib/action\_dispatch/middleware/templates/rescues/\_request\_and\_response.erb (36.4ms) Rendered /usr/lib/ruby/gems/1.8/gems/actionpack-3.0.9/lib/action\_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (40.7ms)

I am sending a http request with only one header param Accept : application/json

Does anyone know about this issue?

Best,

philip

---

<div class="post-metadata">

**Author:** ![11155](https://avatars.discourse-cdn.com/v4/letter/1/d26b3c/32.png) [@11155](https://discuss.rubyonrails.org/u/11155)\
**Post date:** [July 14, 2011, 10:16am UTC](https://discuss.rubyonrails.org/t/rails-3-0-9-argumenterror-redundant-utf-8-sequence/59856/2 "2011-07-14T10:16:24Z")

</div>

Hi,

the problem occurs if you have columns with byte data. to exclude them of the serialization is used

def serializable\_hash(options=nil) &nbsp;&nbsp;&nbsp;&nbsp;options ||= {} &nbsp;&nbsp;&nbsp;&nbsp;options.merge!( :except=\> [:MY\_BYTEDATA\_COLUMN] ) if options[:except].blank? &nbsp;&nbsp;&nbsp;&nbsp;super(options) &nbsp;&nbsp;end

dc dieci wrote in post #1010652:

> Hi guys, I have a simple controller
> 
> &nbsp;&nbsp;def gmap &nbsp;&nbsp;&nbsp;&nbsp;@intentsearches = Intentsearch.all &nbsp;&nbsp;&nbsp;&nbsp;logger.info @intentsearches &nbsp;&nbsp;&nbsp;&nbsp;respond\_to do |format| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;format.html {render :gmap} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;format.xml {render :xml =\> @intentsearches } &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;format.json { render :json =\> @intentsearches } &nbsp;&nbsp;&nbsp;&nbsp;end &nbsp;&nbsp;end
> 
> and want a json response, but i do get the following error
> 
> Completed 500 Internal Server Error in 107ms
> 
> ArgumentError (redundant UTF-8 sequence): &nbsp;&nbsp;app/controllers/intentsearches\_controller.rb:103:in `gmap' &nbsp;&nbsp;app/controllers/intentsearches_controller.rb:100:in `gmap'
> 
> Rendered

/usr/lib/ruby/gems/1.8/gems/actionpack-3.0.9/lib/action\_dispatch/middleware/templates/rescues/\_trace.erb

> (1.0ms) Rendered

/usr/lib/ruby/gems/1.8/gems/actionpack-3.0.9/lib/action\_dispatch/middleware/templates/rescues/\_request\_and\_response.erb

> (36.4ms) Rendered

/usr/lib/ruby/gems/1.8/gems/actionpack-3.0.9/lib/action\_dispatch/middleware/templates/rescues/diagnostics.erb

> within rescues/layout (40.7ms)
> 
> I am sending a http request with only one header param Accept : application/json
> 
> Does anyone know about this issue?
> 
> Best,
> 
> philip
> 
> update: some more investigation revealed the following.
> 
> when i do call the to\_json method in the console on a single object it all works fine. the error occurs only when i get a collection of objects.
> 
> ArgumentError: redundant UTF-8 sequence &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from

/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.9/lib/active\_support/json/encoding.rb:130:in

> `unpack' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from

/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.9/lib/active\_support/json/encoding.rb:130:in

> `escape' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from

/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.9/lib/active\_support/json/encoding.rb:125:in

> `gsub' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from

/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.9/lib/active\_support/json/encoding.rb:125:in

> `escape' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from

/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.9/lib/active\_support/json/encoding.rb:68:in

> `escape' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from

/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.9/lib/active\_support/json/encoding.rb:173:in

> `encode\_json' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from

/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.9/lib/active\_support/json/encoding.rb:47:in

> `encode' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from

/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.9/lib/active\_support/json/encoding.rb:77:in

> `check\_for\_circular\_references' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from

/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.9/lib/active\_support/json/encoding.rb:45:in

> `encode' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from

/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.9/lib/active\_support/json/encoding.rb:247:in

> `encode_json' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from (irb):26:in `map' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from

/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.9/lib/active\_support/json/encoding.rb:247:in

> `each' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from

/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.9/lib/active\_support/json/encoding.rb:247:in

> `map' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from

/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.9/lib/active\_support/json/encoding.rb:247:in

> `encode\_json' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from

/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.9/lib/active\_support/json/encoding.rb:47:in

> `encode' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from

/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.9/lib/active\_support/json/encoding.rb:77:in

> `check\_for\_circular\_references' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from

/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.9/lib/active\_support/json/encoding.rb:45:in

> `encode' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from

/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.9/lib/active\_support/json/encoding.rb:247:in

> `encode_json' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from (irb):26:in `map' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from

/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.9/lib/active\_support/json/encoding.rb:247:in

> `each' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from

/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.9/lib/active\_support/json/encoding.rb:247:in

> `map' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from

/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.9/lib/active\_support/json/encoding.rb:247:in

> `encode\_json' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from

/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.9/lib/active\_support/json/encoding.rb:214:in

> `encode\_json' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from

/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.9/lib/active\_support/json/encoding.rb:214:in

> `map' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from

/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.9/lib/active\_support/json/encoding.rb:214:in

> `encode\_json' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from

/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.9/lib/active\_support/json/encoding.rb:47:in

> `encode' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from

/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.9/lib/active\_support/json/encoding.rb:77:in

> `check\_for\_circular\_references' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from

/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.9/lib/active\_support/json/encoding.rb:45:in

> `encode' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from

/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.9/lib/active\_support/json/encoding.rb:30:in

> `encode' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from

/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.9/lib/active\_support/core\_ext/object/to\_json.rb:15:in
