pact-foundation / pact-mock_service

Provides a mock service for use with Pact
https://pact.io
MIT License
73 stars 69 forks source link

No UTF-8 support using pact-stub-service #87

Closed siad007 closed 6 years ago

siad007 commented 6 years ago

There seems to be a problem in pact-stub-service with UTF-8 encoded pact files.

root@1ddd230f03f7:/code# vendor/mattersight/phppact/pact/bin/pact-stub-service data/consumer-provider.json -p 1234
INFO: Loading interactions from data/consumer-provider.json
/code/vendor/mattersight/phppact/pact/lib/vendor/ruby/2.2.0/gems/json-2.1.0/lib/json/common.rb:156:in `encode': "\xC3" on US-ASCII (Encoding::InvalidByteSequenceError)
    from /code/vendor/mattersight/phppact/pact/lib/vendor/ruby/2.2.0/gems/json-2.1.0/lib/json/common.rb:156:in `initialize'
    from /code/vendor/mattersight/phppact/pact/lib/vendor/ruby/2.2.0/gems/json-2.1.0/lib/json/common.rb:156:in `new'
    from /code/vendor/mattersight/phppact/pact/lib/vendor/ruby/2.2.0/gems/json-2.1.0/lib/json/common.rb:156:in `parse'
    from /code/vendor/mattersight/phppact/pact/lib/vendor/ruby/2.2.0/gems/pact-mock_service-2.6.4/lib/pact/mock_service/app.rb:43:in `block in setup_stub'
    from /code/vendor/mattersight/phppact/pact/lib/vendor/ruby/2.2.0/gems/pact-mock_service-2.6.4/lib/pact/mock_service/app.rb:41:in `collect'
    from /code/vendor/mattersight/phppact/pact/lib/vendor/ruby/2.2.0/gems/pact-mock_service-2.6.4/lib/pact/mock_service/app.rb:41:in `setup_stub'
    from /code/vendor/mattersight/phppact/pact/lib/vendor/ruby/2.2.0/gems/pact-mock_service-2.6.4/lib/pact/mock_service/app.rb:23:in `initialize'
    from /code/vendor/mattersight/phppact/pact/lib/vendor/ruby/2.2.0/gems/pact-mock_service-2.6.4/lib/pact/mock_service/app.rb:14:in `new'
    from /code/vendor/mattersight/phppact/pact/lib/vendor/ruby/2.2.0/gems/pact-mock_service-2.6.4/lib/pact/mock_service/app.rb:14:in `new'
    from /code/vendor/mattersight/phppact/pact/lib/vendor/ruby/2.2.0/gems/pact-mock_service-2.6.4/lib/pact/mock_service/run.rb:35:in `mock_service'
    from /code/vendor/mattersight/phppact/pact/lib/vendor/ruby/2.2.0/gems/pact-mock_service-2.6.4/lib/pact/mock_service/run.rb:26:in `call'
    from /code/vendor/mattersight/phppact/pact/lib/vendor/ruby/2.2.0/gems/pact-mock_service-2.6.4/lib/pact/mock_service/run.rb:11:in `call'
    from /code/vendor/mattersight/phppact/pact/lib/vendor/ruby/2.2.0/gems/pact-mock_service-2.6.4/lib/pact/stub_service/cli.rb:42:in `service'
    from /code/vendor/mattersight/phppact/pact/lib/vendor/ruby/2.2.0/gems/thor-0.20.0/lib/thor/command.rb:27:in `run'
    from /code/vendor/mattersight/phppact/pact/lib/vendor/ruby/2.2.0/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command'
    from /code/vendor/mattersight/phppact/pact/lib/vendor/ruby/2.2.0/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch'
    from /code/vendor/mattersight/phppact/pact/lib/vendor/ruby/2.2.0/gems/thor-0.20.0/lib/thor/base.rb:466:in `start'
    from /code/vendor/mattersight/phppact/pact/lib/vendor/ruby/2.2.0/gems/pact-mock_service-2.6.4/lib/pact/mock_service/cli/custom_thor.rb:17:in `start'
    from /code/vendor/mattersight/phppact/pact/lib/app/pact-stub-service.rb:15:in `<main>'
bethesque commented 6 years ago

Pact php needs to update to the latest version of the ruby standalone, where the encoding is explicitly set to utf-8. In the meantime, you can export the appropriate environment variable for your OS (looks like Linux) to set your encoding as per https://ruby-doc.org/core-2.2.0/Encoding.html. It will probably be LANG=UTF-8. Check your env to see what is currently set.

siad007 commented 6 years ago

Thanks for clarification.