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

test: run http server tck against Micronaut Serialization Jackson #617

Merged
merged 1 commit into from Oct 26, 2023

Conversation

sdelamo
Copy link
Contributor

@sdelamo sdelamo commented Oct 25, 2023

@sdelamo sdelamo requested a review from yawkat October 25, 2023 12:23
@sonarcloud
Copy link

sonarcloud bot commented Oct 25, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

import org.junit.platform.suite.api.SuiteDisplayName;

@Suite
@ExcludeClassNamePatterns("io.micronaut.http.server.tck.tests.constraintshandler.ControllerConstraintHandlerTest")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

that's a weird test, it relies on a NonNull parameter being set to null and then failing later in constraint validation, which works with jackson-databind (doesnt care about NonNull) but not serde. serde's behavior is fine here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It isn't a weird test. It describes a scenario many users will anticipate to work. Myself included. You create a controller with a POJO with the nullability annotations. The POJO describes the valid payload of your endpoint. The person invoking the API does not supply a valid JSON. You expect the object to be populated with the available information and the validation submission to be triggered so that you can handle the ConstraintViolationException. What are you working on

Copy link
Member

Choose a reason for hiding this comment

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

NonNull is not a validation annotation though, it is more fundamental and is checked at a different stage than validation annotations. I see your point, but we can't throw ConstraintViolationException from serde, it's not even on the compile path. And we made the explicit choice to check for null in serde.

Consider it from a different angle. If the JSON included {\"username\":{},\"password\":\"secret\"} (entirely wrong type for username), then both jackson-databind and serde will fail with not-a-ConstraintViolationException. Serde just extends this same behavior to null (or in this case missing fields). The line between a type error and a constraint error has to be drawn somewhere, and serde (intentionally) checks nulls.

@sdelamo
Copy link
Contributor Author

sdelamo commented Oct 26, 2023

@yawkat can you a approve or request changes?

@sdelamo sdelamo merged commit 9fe07da into master Oct 26, 2023
12 checks passed
@sdelamo sdelamo deleted the tck branch October 26, 2023 11:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants