pact-js-core: Encoding Error when publishing pacts
We currently face an encoding problem while publishing pacts to the pact broker from our npm build on a gitlab CI runner.
The same script works fine from our local windows machines and has worked fine on gitlab (unix), too, until we introduced the “€” symbol into the pacts.
This is the stacktrace:
Could not publish pact:
/builds/renew/ui/node_modules/@pact-foundation/pact-standalone/platforms/linux-x64/lib/ruby/lib/ruby/gems/2.2.0/gems/bundler-1.9.9/lib/bundler/shared_helpers.rb:78: warning: Insecure world writable dir /builds/renew/ui/node_modules in PATH, mode 040777
Error making request - Encoding::InvalidByteSequenceError "\xE2" on US-ASCII /builds/renew/ui/node_modules/@pact-foundation/pact-standalone/platforms/linux-x64/lib/vendor/ruby/2.2.0/gems/pact_broker-client-1.14.0/lib/pact_broker/client/pact_file.rb:28:in `pact_hash', attempt 1 of 3
Error making request - Encoding::InvalidByteSequenceError "\xE2" on US-ASCII /builds/renew/ui/node_modules/@pact-foundation/pact-standalone/platforms/linux-x64/lib/vendor/ruby/2.2.0/gems/pact_broker-client-1.14.0/lib/pact_broker/client/pact_file.rb:28:in `pact_hash', attempt 2 of 3
Error making request - Encoding::InvalidByteSequenceError "\xE2" on US-ASCII /builds/renew/ui/node_modules/@pact-foundation/pact-standalone/platforms/linux-x64/lib/vendor/ruby/2.2.0/gems/pact_broker-client-1.14.0/lib/pact_broker/client/pact_file.rb:28:in `pact_hash', attempt 3 of 3
/builds/renew/ui/node_modules/@pact-foundation/pact-standalone/platforms/linux-x64/lib/vendor/ruby/2.2.0/gems/json-2.1.0/lib/json/common.rb:156:in `encode'
:
"\xE2" on US-ASCII
(
Encoding::InvalidByteSequenceError
)
from /builds/renew/ui/node_modules/@pact-foundation/pact-standalone/platforms/linux-x64/lib/vendor/ruby/2.2.0/gems/json-2.1.0/lib/json/common.rb:156:in `initialize'
from /builds/renew/ui/node_modules/@pact-foundation/pact-standalone/platforms/linux-x64/lib/vendor/ruby/2.2.0/gems/json-2.1.0/lib/json/common.rb:156:in `new'
from /builds/renew/ui/node_modules/@pact-foundation/pact-standalone/platforms/linux-x64/lib/vendor/ruby/2.2.0/gems/json-2.1.0/lib/json/common.rb:156:in `parse'
from /builds/renew/ui/node_modules/@pact-foundation/pact-standalone/platforms/linux-x64/lib/vendor/ruby/2.2.0/gems/pact_broker-client-1.14.0/lib/pact_broker/client/pact_file.rb:28:in `pact_hash'
from /builds/renew/ui/node_modules/@pact-foundation/pact-standalone/platforms/linux-x64/lib/vendor/ruby/2.2.0/gems/pact_broker-client-1.14.0/lib/pact_broker/client/pact_file.rb:20:in `consumer_name'
from /builds/renew/ui/node_modules/@pact-foundation/pact-standalone/platforms/linux-x64/lib/vendor/ruby/2.2.0/gems/pact_broker-client-1.14.0/lib/pact_broker/client/publish_pacts.rb:98:in `consumer_name'
from /builds/renew/ui/node_modules/@pact-foundation/pact-standalone/platforms/linux-x64/lib/vendor/ruby/2.2.0/gems/pact_broker-client-1.14.0/lib/pact_broker/client/publish_pacts.rb:80:in `rescue in tag_consumer_version'
from /builds/renew/ui/node_modules/@pact-foundation/pact-standalone/platforms/linux-x64/lib/vendor/ruby/2.2.0/gems/pact_broker-client-1.14.0/lib/pact_broker/client/publish_pacts.rb:73:in `tag_consumer_version'
from /builds/renew/ui/node_modules/@pact-foundation/pact-standalone/platforms/linux-x64/lib/vendor/ruby/2.2.0/gems/pact_broker-client-1.14.0/lib/pact_broker/client/publish_pacts.rb:68:in `block in apply_tags'
from /builds/renew/ui/node_modules/@pact-foundation/pact-standalone/platforms/linux-x64/lib/vendor/ruby/2.2.0/gems/pact_broker-client-1.14.0/lib/pact_broker/client/publish_pacts.rb:67:in `each'
from /builds/renew/ui/node_modules/@pact-foundation/pact-standalone/platforms/linux-x64/lib/vendor/ruby/2.2.0/gems/pact_broker-client-1.14.0/lib/pact_broker/client/publish_pacts.rb:67:in `all?'
from /builds/renew/ui/node_modules/@pact-foundation/pact-standalone/platforms/linux-x64/lib/vendor/ruby/2.2.0/gems/pact_broker-client-1.14.0/lib/pact_broker/client/publish_pacts.rb:67:in `apply_tags'
from /builds/renew/ui/node_modules/@pact-foundation/pact-standalone/platforms/linux-x64/lib/vendor/ruby/2.2.0/gems/pact_broker-client-1.14.0/lib/pact_broker/client/publish_pacts.rb:27:in `call'
from /builds/renew/ui/node_modules/@pact-foundation/pact-standalone/platforms/linux-x64/lib/vendor/ruby/2.2.0/gems/pact_broker-client-1.14.0/lib/pact_broker/client/publish_pacts.rb:13:in `call'
from /builds/renew/ui/node_modules/@pact-foundation/pact-standalone/platforms/linux-x64/lib/vendor/ruby/2.2.0/gems/pact_broker-client-1.14.0/lib/pact_broker/client/cli/broker.rb:125:in `publish_pacts'
from /builds/renew/ui/node_modules/@pact-foundation/pact-standalone/platforms/linux-x64/lib/vendor/ruby/2.2.0/gems/pact_broker-client-1.14.0/lib/pact_broker/client/cli/broker.rb:51:in `publish'
from /builds/renew/ui/node_modules/@pact-foundation/pact-standalone/platforms/linux-x64/lib/vendor/ruby/2.2.0/gems/thor-0.20.0/lib/thor/command.rb:27:in `run'
from /builds/renew/ui/node_modules/@pact-foundation/pact-standalone/platforms/linux-x64/lib/vendor/ruby/2.2.0/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command'
from /builds/renew/ui/node_modules/@pact-foundation/pact-standalone/platforms/linux-x64/lib/vendor/ruby/2.2.0/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch'
from /builds/renew/ui/node_modules/@pact-foundation/pact-standalone/platforms/linux-x64/lib/vendor/ruby/2.2.0/gems/thor-0.20.0/lib/thor/base.rb:466:in `start'
from /builds/renew/ui/node_modules/@pact-foundation/pact-standalone/platforms/linux-x64/lib/vendor/ruby/2.2.0/gems/pact_broker-client-1.14.0/lib/pact_broker/client/cli/custom_thor.rb:15:in `start'
from /builds/renew/ui/node_modules/@pact-foundation/pact-standalone/platforms/linux-x64/lib/app/pact-broker.rb:28:in `<main>'
Any ideas how we can address this issue?
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 1
- Comments: 36 (32 by maintainers)
I’m inclined to agree with @mboudreau on this one. Let’s default it to UTF-8 (I’ll set it in the ruby code so that people’s default locale won’t screw with it), and if someone wants a different encoding, we’ll deal with it then via a different mechanism (eg command line parameter). I’m guessing there is a very low chance of anyone wanting a different encoding, as Michel points out.
I tend to agree. Just as an aside, this issue had encoding set to
ASCII-8BIT. So we might need to be agile if it comes up (and probably worth a documentation note across projects).Back from lunch - so yeah, it totally fixed it in the latest Pact Go build: https://app.wercker.com/Pact-Foundation/pact-go/runs/build/5ab06ebbdfd4d200017900c7?step=5ab06ee5e368b50001097df7
@bethesque I will try with the latest versions and if it still fails create a minimal example to reproduce.