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

Improve quarkus-hibernate-reactive-rest-data-panache Hibernate Validation Violation Errors - Property Path #29047

Closed
StephenOTT opened this issue Nov 3, 2022 · 2 comments · Fixed by #29140

Comments

@StephenOTT
Copy link

StephenOTT commented Nov 3, 2022

Description

Currently when you generate violations such as:

Using a validator on a annotation that is used at the class level and using the generated POST method for entity creation/insert.

entity:

@Entity
@SomeClassLevelConstraint()
public class SomeEntity extends PanacheEntity {
....

Validator

...

public boolean isValid(Object value, ConstraintValidatorContext context) {
     context.buildConstraintViolationWithTemplate("some error").addPropertyNode("some path").addConstraintViolation().disableDefaultConstraintViolation();

...

This generates a json response of:

{
  "title": "Constraint Violation",
  "status": 400,
  "violations": [
    {
      "field": "add.arg0.somepath",
      "message": "some error"
    }
  ]
}

the add.arg0 appears to be coming from RestDataResource with the Entity add(Entity entity); method? (https://github.com/quarkusio/quarkus/blob/main/extensions/panache/rest-data-panache/runtime/src/main/java/io/quarkus/rest/data/panache/RestDataResource.java#L52)

Would be great if we could tailor this so the root makes sense for the output.

Implementation ideas

No response

@quarkus-bot
Copy link

quarkus-bot bot commented Nov 3, 2022

@geoand
Copy link
Contributor

geoand commented Nov 4, 2022

cc @Sgitario

Sgitario added a commit to Sgitario/quarkus that referenced this issue Nov 9, 2022
Sgitario added a commit to Sgitario/quarkus that referenced this issue Nov 9, 2022
@quarkus-bot quarkus-bot bot added this to the 2.15 - main milestone Nov 9, 2022
@gsmet gsmet modified the milestones: 2.15 - main, 2.14.1.Final Nov 10, 2022
gsmet pushed a commit to gsmet/quarkus that referenced this issue Nov 10, 2022
pedroh-pereira pushed a commit to pedroh-pereira/quarkus that referenced this issue Nov 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants