Apicurio / apicurio-registry

An API/Schema registry - stores APIs and Schemas.
https://www.apicur.io/registry/
Apache License 2.0
588 stars 261 forks source link

Improve API input validation and the resulting errors #2479

Open jsenko opened 2 years ago

jsenko commented 2 years ago

When creating an artifact with a very long group name, the issue is caught in the database as a constrain violation, and the resulting HTTP code is 500. We should validate inputs at a higher level, before the request is being processed. In the control plane, we use javax.validation annotations on the DTOs i.e. https://github.com/bf2fc6cc711aee1a0c2a/srs-fleet-manager/blob/main/core/src/main/java/org/bf2/srs/fleetmanager/rest/service/model/RegistryCreateDto.java#L36 , and quarkus-hibernate-validator extension. In Registry, we could do the same if there are suitable DTOs, or validate on REST API beans, which would require updating the codegen.

EricWittmann commented 2 years ago

Quarkus bean validation: https://quarkus.io/guides/validation