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

MWS get_report encoding issues not UTF-8 but UTF8 #144

Closed
NaitoYuki opened this issue Mar 25, 2020 · 2 comments
Closed

MWS get_report encoding issues not UTF-8 but UTF8 #144

NaitoYuki opened this issue Mar 25, 2020 · 2 comments

Comments

@NaitoYuki
Copy link

NaitoYuki commented Mar 25, 2020

Hi,
Thanks for the this library. We are using MWS::Reports::Client.

We are using get_report(request_id) method for _GET_MERCHANT_LISTINGS_ALL_DATA_ report.

some response is the below error. unknown encoding name - UTF8

28640:E, [2020-03-25T19:50:14.690306 #5105] ERROR -- : unknown encoding name - UTF8
28642-E, [2020-03-25T19:50:14.691057 #5105] ERROR -- : /var/www/app/shared/bundle/ruby/2.6.0/gems/peddler-2.1.1/lib/peddler/headers.rb:50:in `find'
28643-/var/www/app/shared/bundle/ruby/2.6.0/gems/peddler-2.1.1/lib/peddler/headers.rb:50:in `content_charset'
28644-/var/www/app/shared/bundle/ruby/2.6.0/gems/peddler-2.1.1/lib/peddler/flat_file_parser.rb:42:in `scrub_body!'
28645-/var/www/app/shared/bundle/ruby/2.6.0/gems/peddler-2.1.1/lib/peddler/flat_file_parser.rb:21:in `initialize'
28646-/var/www/app/shared/bundle/ruby/2.6.0/gems/peddler-2.1.1/lib/peddler/parser.rb:21:in `new'
28647-/var/www/app/shared/bundle/ruby/2.6.0/gems/peddler-2.1.1/lib/peddler/parser.rb:21:in `new'
28648-/var/www/app/shared/bundle/ruby/2.6.0/gems/peddler-2.1.1/lib/peddler/client.rb:118:in `run'
28649-/var/www/app/shared/bundle/ruby/2.6.0/gems/peddler-2.1.1/lib/mws/reports/client.rb:165:in `get_report'

I found the error is the below. match_data is UTF8.
https://github.com/hakanensari/peddler/blob/1e1dde3e597d0ecf1be812468d5001fceb00f59e/lib/peddler/headers.rb#L47

Seems to me something is the wrong encoding pattern.

So, We are avoiding this error for this patch code.

config/initializers/monkey_patches/flat_file_parser.rb

module Peddler
  class FlatFileParser < SimpleDelegator
    def scrub_body!(encoding)
      return if body.encoding == Encoding::UTF_8

      set_charset = content_charset rescue Encoding::UTF_8.to_s
      self.body = body.dup.force_encoding(set_charset || encoding)
    end
  end
end

We hope this error will be resolved.

@hakanensari
Copy link
Member

@NaitoYuki Thanks for reporting, I pushed a fix to master

@NaitoYuki
Copy link
Author

@hakanensari Super Thanks!!!

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