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

Invalid path value for HTTP header matcher. #34

Closed
skaggmannen opened this issue May 22, 2019 · 8 comments
Closed

Invalid path value for HTTP header matcher. #34

skaggmannen opened this issue May 22, 2019 · 8 comments

Comments

@skaggmannen
Copy link

Hi,

Apparently pact-ruby-standalone does not use the standard header path format of $.header.<header name> when parsing pact files. Instead the non-standard format $.headers.<header name> is used (notice the extra s). This leads to incompatibility with pact-jvm (as mentioned in e.g. pact-foundation/pact-net#184 (comment)) which generates the paths according to the pact specification.

Here's the relevant part of the pact specification:

Matcher Path expressions

Pact does not support the full JSON path expressions, only ones that match the following rules:

  1. All paths start with a dollar ($), representing the root.
  2. All path elements are either separated by periods (.) or use the JSON path bracket notation (square brackets and single quotes around the values: e.g. ['x.y']), except array indices which use square brackets ([]). For elements where the value contains white space or non-alphanumeric characters, the JSON path bracket notation (['']) should be used.
  3. The second element of the path is the http type that the matcher is applied to (e.g., $.body or $.header).
  4. Path elements represent keys.
  5. A star (*) can be used to match all keys of a map or all items of an array (one level only).
@bethesque
Copy link
Member

According to this example in the specification, it's "headers" not "header"

https://github.com/pact-foundation/pact-specification/blob/version-2/testcases/response/headers/matches%20with%20regex.json

@uglyog?

@uglyog
Copy link
Member

uglyog commented May 23, 2019

Version 2 is headers, version 3 is header. See comment on pact-foundation/pact-jvm#882

@bethesque
Copy link
Member

What was the reason for changing it @uglyog?

Pact Ruby doesn't fully support v3, but I'll see if I can get that rule in.

@skaggmannen
Copy link
Author

@uglyog if that's the case, shouldn't pact-jvm use headers when generating V2 pacts? From the issue you linked to that I created (and closed) you can see that it uses header even for V2.

@uglyog
Copy link
Member

uglyog commented May 24, 2019

You may have a valid point there.

@bethesque
Copy link
Member

Oh, are you using v2 @skaggmannen? Looks like we both have to write some dirty code @uglyog :P

@bethesque
Copy link
Member

I've opened an issue in pact-support to support the v3 "header", and I'm closing this. @skaggmannen can you raise in issue in pact-jvm for the v2 "headers"?

pact-foundation/pact-support#67

@skaggmannen
Copy link
Author

Sorry, I did not mean to ghost you, I've just been very busy. I can see that @uglyog has already re-opened the issue I raised on pact-jvm (pact-foundation/pact-jvm#882) so I think that's taken care of.

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

3 participants