Skip to content

Fix: @Valid validation and BrandDto type safety (Epic 5 follow-up)#137

Open
devin-ai-integration[bot] wants to merge 1 commit into
migration/complete-java-migration-v4from
devin/1779830457-fix-validation-and-dto
Open

Fix: @Valid validation and BrandDto type safety (Epic 5 follow-up)#137
devin-ai-integration[bot] wants to merge 1 commit into
migration/complete-java-migration-v4from
devin/1779830457-fix-validation-and-dto

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented May 26, 2026

Copy link
Copy Markdown

Summary

Addresses two issues identified by Devin Review on the merged Epic 5 PR (#136):

  1. Remove @NotNull from catalogType and catalogBrand ManyToOne fields in CatalogItem — Spring MVC form binding only populates simple/primitive fields (catalogTypeId, catalogBrandId), not JPA @ManyToOne relationships. With @NotNull on these fields, @Valid always fails because they are always null after binding, making create and edit forms completely non-functional. Database-level enforcement is retained via @JoinColumn(nullable = false).

  2. Change BrandDto.id from primitive int to IntegerCatalogBrand.getId() returns Integer (nullable). Using primitive int in the record risks NullPointerException on auto-unboxing if an unsaved entity ever has a null ID.

Review & Testing Checklist for Human

  • Start the app with mvn spring-boot:run and 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)
  • Test the Edit flow — verify that editing an existing item saves changes
  • Verify that submitting an invalid form (e.g. empty name, negative price) correctly shows validation errors

Notes

Link to Devin session: https://partner-workshops.devinenterprise.com/sessions/b11d8bbaa2824ef5ad393e5afc60b18e
Requested by: @mbatchelor81


Open in Devin Review

- 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.
@devin-ai-integration

Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 1 additional finding.

Open in Devin Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant