Encoding Error when publishing pacts
See original GitHub issueWe 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?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:36 (32 by maintainers)
Top Results From Across the Web
Encoding Error when publishing pacts · Issue #75 - GitHub
We currently face an encoding problem while publishing pacts to the pact broker from our npm build on a gitlab CI runner.
Read more >pact_verifier | Pact Docs
c12d9a61 - fix: Verification results across multiple pacts accumulate, publishing invalid results #231 (Ronald Holshausen, Mon Nov 28 12:00:38 ...
Read more >Publishing Consumer Contract from Multiple Pact Files
The error you are getting is that you are publishing the contract to a Pact Broker (Pactflow) with the same consumer version number....
Read more >Verify Pact Contract And Continuous Deployment With Pact CLI
In this tutorial, we will look at how to set up a provider test, manage state, verify the contract, and deploy using Pact...
Read more >@pact-foundation/pact - npm
Pact publishing options; Publishing Verification Results to a Pact ... and expected occurred // this will throw an error if it fails telling ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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).