-
-
Notifications
You must be signed in to change notification settings - Fork 481
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
Whitespace removed from header include validation #1704
Comments
The issue you're facing seems to be related to how the whitespace in the header value is handled during contract verification between the consumer (Pact JS) and the provider (Pact JVM). It looks like the whitespace is being removed from the expected result during the verification process, causing the test to fail. The problem is likely due to a difference in how the two implementations (Pact JS and Pact JVM) handle the matching of headers, specifically when using the MatchersV3.includes with whitespace. |
Option; You can use Different Matcher: |
You shouldn't rely on the whitespace, it is optional in these types of headers. Some HTTP clients and servers will include the white space, others will not. |
It seems like you’re referring to the whitespace in HTTP headers. In HTTP headers, whitespace after the colon (:) that separates the header name from its value is indeed optional. While many implementations include it for readability, it’s not a requirement according to the HTTP/1.1 specification (RFC 7230). |
Not only that, but headers that follow the ABNF form (like Content-Type, Accept and I assume Content-Disposition), the white space around parameters are also optional. So |
I agree that space is optional, so in that case, the Provider should NOT validate the space, right? |
Yes, you can use a regex instead to match any amount of whitespace, i.e. |
Or Suggested Update to Pact JS Code latest versions of both Pact JS and Pact JVM. Sometimes updating can resolve these inconsistencies. |
But we have a header which isnt actually following the ABNF form and when i update pact plugin to latest it is adding an extraspace after semicolon and this shouldnt be the case. Older version of pact 4.5.6 wasnt doing this but with 4.6.14 it was adding an extra whitespace and controller was failing these scenarios from provider verification standpoint. |
Pact JVM version (maven):
In consumer (Pact JS) I add an expected result with
MatchersV3.includes
that has a whitespace:This generates a contract with the following (it has the whitespace):
However, when provider (Pact JVM) verifies this contract, it fails with the following error - the whitespace was removed from the expected result
This test should pass, the whitespace should not be removed from the validation.
The text was updated successfully, but these errors were encountered: