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

Encoding::CompatibilityError on Linux 64bit #5

Open
mefellows opened this issue Aug 5, 2017 · 9 comments
Open

Encoding::CompatibilityError on Linux 64bit #5

mefellows opened this issue Aug 5, 2017 · 9 comments

Comments

@mefellows
Copy link
Member

Getting an Encoding::CompatibilityError when running pact verification on Linux 64bit (consumer test is fine) with a pact containing unicode (chinese) characters. It also fails with emojis.

Runtime details:

Note that I've tested this on OSX and it's not a problem.

Command:

./pact/bin/pact-provider-verifier  --pact-urls ./matching_service-animal_profile_service.json --provider-base-url http://localhost:8000

Stack trace:

ubuntu@ip-172-30-13-202:/tmp$ ./pact/bin/pact-provider-verifier  --pact-urls ./matching_service-animal_profile_service.json --provider-base-url http://localhost:8000
Reading pact at ./matching_service-animal_profile_service.json
/tmp/pact/lib/vendor/ruby/2.2.0/gems/json-1.8.6/lib/json/pure/parser.rb:242:in `rescue in parse_string': Caught Encoding::CompatibilityError at '{ (JSON::ParserError)
  "consumer": {
  ': incompatible encoding regexp match (ASCII-8BIT regexp with UTF-8 string)
	from /tmp/pact/lib/vendor/ruby/2.2.0/gems/json-1.8.6/lib/json/pure/parser.rb:213:in `parse_string'
	from /tmp/pact/lib/vendor/ruby/2.2.0/gems/json-1.8.6/lib/json/pure/parser.rb:257:in `parse_value'
	from /tmp/pact/lib/vendor/ruby/2.2.0/gems/json-1.8.6/lib/json/pure/parser.rb:121:in `parse'
	from /tmp/pact/lib/vendor/ruby/2.2.0/gems/json-1.8.6/lib/json/common.rb:155:in `parse'
	from /tmp/pact/lib/vendor/ruby/2.2.0/gems/json-1.8.6/lib/json/common.rb:334:in `load'
	from /tmp/pact/lib/vendor/ruby/2.2.0/gems/pact-support-1.1.5/lib/pact/consumer_contract/consumer_contract.rb:42:in `from_json'
	from /tmp/pact/lib/vendor/ruby/2.2.0/gems/pact-1.14.0/lib/pact/provider/rspec.rb:25:in `honour_pactfile'
	from /tmp/pact/lib/vendor/ruby/2.2.0/gems/pact-1.14.0/lib/pact/provider/pact_spec_runner.rb:129:in `block in initialize_specs'
	from /tmp/pact/lib/vendor/ruby/2.2.0/gems/pact-1.14.0/lib/pact/provider/pact_spec_runner.rb:125:in `each'
	from /tmp/pact/lib/vendor/ruby/2.2.0/gems/pact-1.14.0/lib/pact/provider/pact_spec_runner.rb:125:in `initialize_specs'
	from /tmp/pact/lib/vendor/ruby/2.2.0/gems/pact-1.14.0/lib/pact/provider/pact_spec_runner.rb:34:in `run'
	from /tmp/pact/lib/vendor/ruby/2.2.0/gems/pact-1.14.0/lib/pact/cli/run_pact_verification.rb:60:in `run_with_pact_uri'
	from /tmp/pact/lib/vendor/ruby/2.2.0/gems/pact-1.14.0/lib/pact/cli/run_pact_verification.rb:48:in `run_specs'
	from /tmp/pact/lib/vendor/ruby/2.2.0/gems/pact-1.14.0/lib/pact/cli/run_pact_verification.rb:22:in `call'
	from /tmp/pact/lib/vendor/ruby/2.2.0/gems/pact-1.14.0/lib/pact/cli/run_pact_verification.rb:14:in `call'
	from /tmp/pact/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.1.4/lib/pact/provider_verifier/app.rb:66:in `block in verify_pacts'
	from /tmp/pact/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.1.4/lib/pact/provider_verifier/app.rb:57:in `collect'
	from /tmp/pact/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.1.4/lib/pact/provider_verifier/app.rb:57:in `verify_pacts'
	from /tmp/pact/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.1.4/lib/pact/provider_verifier/cli.rb:21:in `verify'
	from /tmp/pact/lib/vendor/ruby/2.2.0/gems/thor-0.19.4/lib/thor/command.rb:27:in `run'
	from /tmp/pact/lib/vendor/ruby/2.2.0/gems/thor-0.19.4/lib/thor/invocation.rb:126:in `invoke_command'
	from /tmp/pact/lib/vendor/ruby/2.2.0/gems/thor-0.19.4/lib/thor.rb:369:in `dispatch'
	from /tmp/pact/lib/vendor/ruby/2.2.0/gems/thor-0.19.4/lib/thor/base.rb:444:in `start'
	from /tmp/pact/lib/app/pact-provider-verifier.rb:2:in `<main>'

Pact file (matching_service-animal_profile_service.json):

{
  "consumer": {
    "name": "Matching Service"
  },
  "provider": {
    "name": "Animal Profile Service"
  },
  "interactions": [
    {
      "description": "a request for projects",
      "provider_state": "i have a list of projects",
      "request": {
        "method": "GET",
        "path": "/projects",
      },
      "response": {
        "status": 200,
        "body": [
          {
            "name": "Project 好"
          }
        ]
      }
    }
  ],
  "metadata": {
    "pactSpecificationVersion": "2.0.0"
  }
}

See pact-foundation/pact-go#41 for original issue.

@mefellows
Copy link
Member Author

FWIW upgrading the json gem from 1.8.6 to 2.1.0 removed this issue, I'm not sure if we can use that version of json though, I seem to recall there was a reason for not using 2+?

@mefellows
Copy link
Member Author

Interestingly, if I remove the 1.8.6 gem directory and let it use the default JSON library with the Ruby distribution (v1.8.1), this test passes again (at least, it parses the JSON document which was the previous friction point).

@bethesque
Copy link
Member

Let's upgrade the json then, I'm pretty sure it's ok.

@bethesque
Copy link
Member

(Or rather, I can't remember it being an issue, guess we'll try and find out)

@bethesque
Copy link
Member

Looks like the restriction was coming from pact-provider-verifier. I'll put a new release out.

@mefellows
Copy link
Member Author

Cool - thanks! I'm in the process of going through updating stuff from the workshop and also those npm packages. Can look at this after

@mefellows
Copy link
Member Author

FWIW I pulled latest standalone, upgraded to latest verifier (bundle update) and ran this test again - fixed it. Upgrading pact-go now...

@bethesque
Copy link
Member

Win

@mefellows
Copy link
Member Author

OK so something happened between that release and the latest published (1.3.1 at the time tested) where it came back, albeit with a different error:

With unicode chars: https://app.wercker.com/Pact-Foundation/pact-go/runs/build/598987263b92d9000169ec86?step=5989872cf250ac0001df5608

Without: https://app.wercker.com/Pact-Foundation/pact-go/runs/build/598985ff3b92d9000169eae7

Still investigating, this is just an update.

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