pact-foundation / pact-ruby

Enables consumer driven contract testing, providing a mock service and DSL for the consumer project, and interaction playback and verification for the service provider project.
https://pact.io
MIT License
2.17k stars 216 forks source link

Unable to use provider tag in publish results #233

Closed rmzoni closed 3 years ago

rmzoni commented 3 years ago

Context

When I use the app_version_tags in provider verification results, I'm receiving an error that contains a new line character in the response json.

bethesque commented 3 years ago

If you're using a git command to get your branch name, you'll need to do a .strip on it to remove the new line character on the end. eg.

`git name-rev --name-only HEAD`.strip
rmzoni commented 3 years ago

If you're using a git command to get your branch name, you'll need to do a .strip on it to remove the new line character on the end. eg.

`git name-rev --name-only HEAD`.strip

Hi, I made this and for test purpose i fixed the tag. But, the problem persists.

bethesque commented 3 years ago

You're hitting this middleware so there must be a new line in there somewhere.

https://github.com/pact-foundation/pact_broker/blob/master/lib/rack/pact_broker/invalid_uri_protection.rb#L49

Try setting verbose true in the honours_pacts_from_pact_broker configuration. It will show you the HTTP output.

rmzoni commented 3 years ago

You're hitting this middleware so there must be a new line in there somewhere.

https://github.com/pact-foundation/pact_broker/blob/master/lib/rack/pact_broker/invalid_uri_protection.rb#L49

Try setting verbose true in the honours_pacts_from_pact_broker configuration. It will show you the HTTP output.

Thanks for the response. But verbose configuration only log requests for the verification process.

The publish requests were not been logging. The error remains the same.

bethesque commented 3 years ago

Look at the log.

INFO: Tagging version c6c2de20e5e1f1b9d51259db1964fd20d786f6da
 of scp as "master"

There's a new line after the version number. It's showing in the log itself.

rmzoni commented 3 years ago

It really was the /n but in the provider version like you mentioned before. @bethesque thanks to be so helpful.

I think it would be nice to update the pact documentation to use strip: https://docs.pact.io/implementation_guides/ruby/verifying_pacts#publishing-verification-results-to-a-pact-broker

provider_version = (ENV['GIT_COMMIT'] || `git rev-parse --verify HEAD`).strip
provider_branch = (ENV['GIT_BRANCH'] || `git name-rev --name-only HEAD`).strip
bethesque commented 3 years ago

Done! https://docs.pact.io/implementation_guides/ruby/verifying_pacts#publishing-verification-results-to-a-pact-broker