Fix Max Size Validation on First Upload#743
Conversation
There was a problem hiding this comment.
The pull request is a clean refactor that correctly fixes the root bug (max-size annotation was previously read from instance data via CdsDataProcessor, which failed on first upload when no existing data existed) by reading it directly from the CdsEntity model metadata instead. The new getValMaxValue implementation is simpler, stateless, and correct.
The only issue posted is a minor dead-code redundancy in the Optional filter chain (v != null is unreachable after .map()), which should be cleaned up for clarity.
PR Bot Information
Version: 1.17.99 | 📖 Documentation | 🚨 Create Incident | 💬 Feedback
- Correlation ID:
974cd160-1b9f-11f1-8bf2-ad3c1b2f22ca - Event Trigger:
pull_request.opened - LLM:
anthropic--claude-4.6-sonnet
...ds/feature/attachments/handler/applicationservice/helper/ModifyApplicationHandlerHelper.java
Outdated
Show resolved
Hide resolved
…chments/handler/applicationservice/helper/ModifyApplicationHandlerHelper.java Co-authored-by: hyperspace-insights[bot] <209611008+hyperspace-insights[bot]@users.noreply.github.com>
|
For Context: |
Fix Max Size Validation on First Upload
Bug Fix
🐛 Fixed an issue where the
Validation.Maximumsize constraint was not being applied correctly on the first upload of an attachment. The previous implementation relied on processing existing attachment data to extract the size annotation, which caused validation to be skipped when no prior attachments existed (e.g., on a brand-new draft).Changes
ModifyApplicationHandlerHelper.java: RefactoredgetValMaxValueto read theValidation.Maximumannotation directly from theCdsEntityelement definition instead of iterating over existing attachment data. This ensures the size limit is always enforced regardless of whether prior attachments exist. Also removed the now-unusedVALMAX_FILTERstatic field and theAtomicReference/CdsDataProcessorimports.ModifyApplicationHandlerHelperTest.java: Updated unit test setup to use an empty existing attachments list (List.<Attachments>of()) in the size-validation test cases, reflecting the fixed behavior where validation works even without pre-existing data.SizeLimitedAttachmentsSizeValidationDraftTest.java: Added two new integration tests:uploadContentWithinLimitAndActivateDraftSucceeds— verifies that a 3MB upload (within a 5MB limit) on a new draft succeeds and the draft can be prepared and activated.uploadContentExceedingLimitOnFirstDraftRejects— verifies that a 6MB upload on a brand-new draft is correctly rejected with HTTP 413.pom.xml: Bumped latest test versions of CAP Java (4.7.0) andcds-dk(9.7.2) used in integration tests.📬 Subscribe to the Hyperspace PR Bot DL to get the latest announcements and pilot features!
PR Bot Information
Version:
1.17.99| 📖 Documentation | 🚨 Create Incident | 💬 Feedbackpull_request.opened974cd160-1b9f-11f1-8bf2-ad3c1b2f22caanthropic--claude-4.6-sonnet