Fix: @Valid validation and BrandDto type safety (Epic 5 follow-up)#137
Open
devin-ai-integration[bot] wants to merge 1 commit into
Open
Conversation
- Remove @NotNull from catalogType and catalogBrand ManyToOne fields in CatalogItem. Spring MVC form binding does not resolve JPA relationships, so these were always null causing @Valid to always fail. Database-level enforcement via @joincolumn(nullable=false) is retained. - Change BrandDto.id from primitive int to Integer to match CatalogBrand.getId() return type and avoid NPE on auto-unboxing.
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Addresses two issues identified by Devin Review on the merged Epic 5 PR (#136):
Remove
@NotNullfromcatalogTypeandcatalogBrandManyToOne fields inCatalogItem— Spring MVC form binding only populates simple/primitive fields (catalogTypeId,catalogBrandId), not JPA@ManyToOnerelationships. With@NotNullon these fields,@Validalways fails because they are alwaysnullafter binding, making create and edit forms completely non-functional. Database-level enforcement is retained via@JoinColumn(nullable = false).Change
BrandDto.idfrom primitiveinttoInteger—CatalogBrand.getId()returnsInteger(nullable). Using primitiveintin the record risksNullPointerExceptionon auto-unboxing if an unsaved entity ever has a null ID.Review & Testing Checklist for Human
mvn spring-boot:runand test the Create flow — verify that submitting a valid form successfully creates a catalog item (previously this would always re-render the form with errors)Notes
mvn clean compilepasses locally"Link to Devin session: https://partner-workshops.devinenterprise.com/sessions/b11d8bbaa2824ef5ad393e5afc60b18e
Requested by: @mbatchelor81