Skip to content

Add ObjectMapper unescaping ASCII control characters when using DTOs#1429

Merged
arcuri82 merged 15 commits intomasterfrom
phg/objectMapper-v2
Feb 6, 2026
Merged

Add ObjectMapper unescaping ASCII control characters when using DTOs#1429
arcuri82 merged 15 commits intomasterfrom
phg/objectMapper-v2

Conversation

@Pgarrett
Copy link
Collaborator

@Pgarrett Pgarrett commented Jan 22, 2026

ASCII control characters were being escaped by Jackson when using DTOs. Control characters in a JSON payload generate an invalid payload, which was being tested by EvoMaster. As such, we created a custom object mapper that will not escape the ASCII control characters, allowing for incorrect payloads to be tested.

@Pgarrett Pgarrett changed the title Phg/object mapper v2 Add ObjectMapper unescaping ASCII control characters when using DTOs Jan 22, 2026
@Pgarrett Pgarrett marked this pull request as ready for review January 22, 2026 20:15
@Pgarrett Pgarrett requested a review from arcuri82 January 22, 2026 20:15
@Pgarrett Pgarrett requested a review from arcuri82 January 28, 2026 02:25
@Pgarrett
Copy link
Collaborator Author

Pgarrett commented Feb 5, 2026

Ready for re-review @arcuri82!

* Control characters break JSON and transform it into an invalid payload. If there's any invalid character
* then we'll avoid using DTOs and have the payload in the test case be represented by the raw JSON string.
*/
private fun payloadIsValidJson(bodyParam: BodyParam): Boolean {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this function, or parts of it (if taking as input a string and not a BodyParam), should go to org.evomaster.core.output.JsonUtils . also, we need unit tests for it, to make sure it works (eg, you can re-use the exact same JSON payload that was failing the E2E test)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, looks like there is also a TestWriterUtils in the same package having functions for JSON, including a call to OutputFormatter.JSON_FORMATTER.isValid(json) where the same type of check is done. maybe better to call that directly

* Control characters break JSON and transform it into an invalid payload. If there's any invalid character
* then we'll avoid using DTOs and have the payload in the test case be represented by the raw JSON string.
*/
private fun payloadIsValidJson(bodyParam: BodyParam): Boolean {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, looks like there is also a TestWriterUtils in the same package having functions for JSON, including a call to OutputFormatter.JSON_FORMATTER.isValid(json) where the same type of check is done. maybe better to call that directly

@Pgarrett Pgarrett requested a review from arcuri82 February 5, 2026 13:27
Copy link
Collaborator

@arcuri82 arcuri82 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happened to the also, we need unit tests for it, to make sure it works (eg, you can re-use the exact same JSON payload that was failing the E2E test) ? :)

@Pgarrett
Copy link
Collaborator Author

Pgarrett commented Feb 5, 2026

what happened to the also, we need unit tests for it, to make sure it works (eg, you can re-use the exact same JSON payload that was failing the E2E test) ? :)

Sorry!! Had missed that comment! Just pushed

@Pgarrett Pgarrett requested a review from arcuri82 February 5, 2026 16:39
@arcuri82 arcuri82 merged commit 366c59c into master Feb 6, 2026
13 checks passed
@arcuri82 arcuri82 deleted the phg/objectMapper-v2 branch February 6, 2026 07:54
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

Successfully merging this pull request may close these issues.

2 participants