quarkus: Validation is not working on Spring REST Data on Native

Describe the bug Spring REST Data extension stopped working when using validations in Native.

This is a regression issue caused by this commit: https://github.com/quarkusio/quarkus/commit/8c76e39060f6b288eaaeeb28bc477b33a972a40f.

This is how my Spring endpoint looks like:

@RepositoryRestResource(exported=false, path = "books", collectionResourceRel = "books")
public interface BookRepository extends PagingAndSortingRepository<Book, Long> {

    @Override
    @RestResource(exported = true)
    Page<Book> findAll(Pageable pageable);

    @RestResource(exported = true)
    List<Book> findByOrderByNameDesc();

    @Override
    @RestResource(path = "id")
    Optional<Book> findById(Long id);

    @Override
    @RestResource
    Book save(Book book);
}

And my entity:

@Entity
public class Book {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Length(min = 2, max = 50, message = "length must be between {min} and {max}")
    @NotBlank(message = "Name may not be blank")
    private String name;

    @Length(min = 2, max = 50, message = "length must be between {min} and {max}")
    @NotBlank(message = "Author may not be blank")
    private String author;

    @JsonBackReference
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "library_id")
    private Library library;
// ...

When calling a POST/PUT endpoint and the validation fails, the endpoint fails with Internal Server Error:

Internal Server Error - Error id 7839b916-3415-4673-8059-572770e26c35-1

Expectation is that it should return the constraint violations. Note that the same is working fine in JVM. I’ve reverted the above commit and everything works in JVM and Native.

To Reproduce

1- git clone https://github.com/Sgitario/beefy-scenarios 2- git checkout reproducer_15409 3- cd beefy-scenarios/602-spring-data-rest 4- mvn clean verify -Dquarkus.native.builder-image=quay.io/quarkus/ubi-quarkus-native-image:21.0.0-java11 -Dnative -Dquarkus.native.container-build=true -Dquarkus.native.native-image-xmx=4g (it needs to have built quarkus master locally)

Environment (please complete the following information): Quarkus version or git rev: 999-SNAPSHOT (1.12.1.Final)

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15 (12 by maintainers)

Most upvoted comments

We can prepare https://github.com/quarkusio/quarkus-ecosystem-ci integration. This way you will get GH notifications directly?