-
-
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
Encoding issue when generating pact containing accented characters #1536
Comments
How is the pact verification failing? Can you provide the error messages? The UTF escape codes should still represent the same characters. |
This issue hasn't seen a lot of activity recently. However, I'm having a similar issue. Any non-ASCII characters are escaped with their unicode code, even though the pact file is UTF-8. I'm running into problems when the pact cli is trying to upload it: https://www.linen.dev/s/pact-foundation/t/23419250/hello-i-got-a-problem-with-the-regex-generator-and-the-pact- . |
If i get it correctly, Pact JVM had sometime made changes to not escape unicode chars: #395 |
That change was a long time ago. It does escape all characters now. |
It uses the Apache Commons Text library to correctly encode the strings, and I doubt that library does not do the correct thing. So this is an issue with the pact cli. |
Although, looking at the code, it is using the ESCAPE_JAVA translator which has a high code point of 0x7f, while there is an ESCAPE_JSON translator that has a high code point of 0x7e. That only differs by 1, and I have no idea what the difference would be. |
Despite some research, I don't really get what that means, but I can say that the generated escape sequences match the original symbols and with some characters like the german "ö" the pact cli doesn't seem to have a problem. So this does in fact look like an issue with the CLI. I suspect that the problem that the original author of this issue had might have been similar. |
In a Java project using pact junit5 4.2.11, and I have encoding issues.
When generating a Pact, the response body is read from a json file containing accented characters (é, è, ü, etc)
When the pact is generated, those characters are replaced with their unicode encoding.
Then on the producer side, when running the test, the pact verification fails due to those encoded characters.
This is the test code :
And here is an extract of the generated pact with encoded characters :
While debugging I can see that until this line
pact-jvm/core/model/src/main/kotlin/au/com/dius/pact/core/model/PactWriter.kt
Line 66 in 4712d32
Therefore I guess something happens in the Json.prettyPrint() function, but I can’t debug inside.
The text was updated successfully, but these errors were encountered: