jhipster / generator-jhipster

JHipster is a development platform to quickly generate, develop, & deploy modern web applications & microservice architectures.
https://www.jhipster.tech
Apache License 2.0
21.53k stars 4.02k forks source link

@Valid annotation missing #23651

Closed Spark61 closed 6 months ago

Spark61 commented 1 year ago
Overview of the issue

The @Valid annotation is not being generated for the patch request in the code. As a result, when a non-valid request is made, it results in a 500 error response instead of a more descriptive validation error.

Motivation for or Use Case

This is crucial for providing a more descriptive and accurate error message to clients, helping in quicker debugging and ensuring better user experience.

Reproduce the error
  1. Define an entity with validation rules as mentioned in the JDL file.
  2. Generate the code using JHipster.
  3. Observe the missing @Valid annotation in the patch request.
Related issues

I've searched the issues both open and closed and couldn't find a similar problem. If it exists and I missed it, my apologies.

Suggest a Fix

Please add the @Valid annotation to the generated patch request to ensure validations are performed before processing the request.

JHipster Version(s)

7.9.4

JHipster configuration

To replicate this issue, you can use the following JDL configuration:

JDL definitions
application {
    config {
        baseName test
        applicationType monolith
        packageName test
        authenticationType oauth2
        prodDatabaseType postgresql
        clientFramework react
        searchEngine elasticsearch
        cacheProvider redis
        enableHibernateCache true
        buildTool gradle
    }
    entities *
}

entity Test {
    name String minlength(3) maxlength(64) pattern(/^[a-zA-Z0-9-_]+\d$/)
}
// Set pagination options
paginate * with infinite-scroll

// Use Data Transfer Objects (DTO)
dto * with mapstruct

// Set service options to all except few
search * with elasticsearch
  
Entity configuration(s) entityName.json files generated in the .jhipster directory

The configuration can be derived from the above JDL, specifically the Test entity and its validations.

Browsers and Operating System

OS: Windows 11 This is not browser-specific.

mshima commented 1 year ago

It’s a patch operation. The validation should be performed after merging with the entity.

github-actions[bot] commented 6 months ago

This issue is stale because it has been open for too long without any activity. Due to the moving nature of jhipster generated application, bugs can become invalid. If this issue still applies please comment otherwise it will be closed in 7 days