diff --git a/cds-feature-attachments/src/main/java/com/sap/cds/feature/attachments/handler/applicationservice/CreateAttachmentsHandler.java b/cds-feature-attachments/src/main/java/com/sap/cds/feature/attachments/handler/applicationservice/CreateAttachmentsHandler.java index 6a10baf6..8372bc68 100644 --- a/cds-feature-attachments/src/main/java/com/sap/cds/feature/attachments/handler/applicationservice/CreateAttachmentsHandler.java +++ b/cds-feature-attachments/src/main/java/com/sap/cds/feature/attachments/handler/applicationservice/CreateAttachmentsHandler.java @@ -82,10 +82,12 @@ void restoreError(EventContext context) { String maxSizeStr = (String) context.get("attachment.MaxSize"); if (maxSizeStr != null) { throw new ServiceException( - ExtendedErrorStatuses.CONTENT_TOO_LARGE, "AttachmentSizeExceeded", maxSizeStr); + ExtendedErrorStatuses.CONTENT_TOO_LARGE, + "File size exceeds the limit of {}.", + maxSizeStr); } throw new ServiceException( - ExtendedErrorStatuses.CONTENT_TOO_LARGE, "AttachmentSizeExceeded"); + ExtendedErrorStatuses.CONTENT_TOO_LARGE, "File size exceeds the limit."); } throw e; } diff --git a/cds-feature-attachments/src/main/java/com/sap/cds/feature/attachments/handler/applicationservice/helper/ModifyApplicationHandlerHelper.java b/cds-feature-attachments/src/main/java/com/sap/cds/feature/attachments/handler/applicationservice/helper/ModifyApplicationHandlerHelper.java index 7f502489..2c315bbe 100644 --- a/cds-feature-attachments/src/main/java/com/sap/cds/feature/attachments/handler/applicationservice/helper/ModifyApplicationHandlerHelper.java +++ b/cds-feature-attachments/src/main/java/com/sap/cds/feature/attachments/handler/applicationservice/helper/ModifyApplicationHandlerHelper.java @@ -94,7 +94,9 @@ public static InputStream handleAttachmentForEntity( maxSizeStr); // make max size available in context for error handling later ServiceException tooLargeException = new ServiceException( - ExtendedErrorStatuses.CONTENT_TOO_LARGE, "AttachmentSizeExceeded", maxSizeStr); + ExtendedErrorStatuses.CONTENT_TOO_LARGE, + "File size exceeds the limit of {}.", + maxSizeStr); if (contentLength != null) { try { diff --git a/cds-feature-attachments/src/main/java/com/sap/cds/feature/attachments/handler/applicationservice/readhelper/CountingInputStream.java b/cds-feature-attachments/src/main/java/com/sap/cds/feature/attachments/handler/applicationservice/readhelper/CountingInputStream.java index db4ec377..f297e0ad 100644 --- a/cds-feature-attachments/src/main/java/com/sap/cds/feature/attachments/handler/applicationservice/readhelper/CountingInputStream.java +++ b/cds-feature-attachments/src/main/java/com/sap/cds/feature/attachments/handler/applicationservice/readhelper/CountingInputStream.java @@ -81,7 +81,9 @@ private void checkLimit(long bytes) { byteCount += bytes; if (byteCount > maxBytes) { throw new ServiceException( - ExtendedErrorStatuses.CONTENT_TOO_LARGE, "AttachmentSizeExceeded", maxBytesString); + ExtendedErrorStatuses.CONTENT_TOO_LARGE, + "File size exceeds the limit of {}.", + maxBytesString); } } } diff --git a/cds-feature-attachments/src/main/resources/messages.properties b/cds-feature-attachments/src/main/resources/messages.properties deleted file mode 100644 index e9af11c9..00000000 --- a/cds-feature-attachments/src/main/resources/messages.properties +++ /dev/null @@ -1 +0,0 @@ -AttachmentSizeExceeded = File size exceeds the limit of {0}. \ No newline at end of file diff --git a/cds-feature-attachments/src/test/java/com/sap/cds/feature/attachments/handler/applicationservice/CreateAttachmentsHandlerTest.java b/cds-feature-attachments/src/test/java/com/sap/cds/feature/attachments/handler/applicationservice/CreateAttachmentsHandlerTest.java index 4eabcf23..f79504ff 100644 --- a/cds-feature-attachments/src/test/java/com/sap/cds/feature/attachments/handler/applicationservice/CreateAttachmentsHandlerTest.java +++ b/cds-feature-attachments/src/test/java/com/sap/cds/feature/attachments/handler/applicationservice/CreateAttachmentsHandlerTest.java @@ -340,7 +340,7 @@ void restoreError_contentTooLargeWithMaxSize_throwsWithMaxSize() { var exception = assertThrows(ServiceException.class, () -> cut.restoreError(context)); assertThat(exception.getErrorStatus()).isEqualTo(ExtendedErrorStatuses.CONTENT_TOO_LARGE); - assertThat(exception.getMessage()).contains("AttachmentSizeExceeded"); + assertThat(exception.getMessage()).contains("File size exceeds the limit of 10MB."); assertThat(exception).isNotSameAs(originalException); } @@ -355,7 +355,7 @@ void restoreError_contentTooLargeWithoutMaxSize_throwsWithoutMaxSize() { var exception = assertThrows(ServiceException.class, () -> cut.restoreError(context)); assertThat(exception.getErrorStatus()).isEqualTo(ExtendedErrorStatuses.CONTENT_TOO_LARGE); - assertThat(exception.getMessage()).contains("AttachmentSizeExceeded"); + assertThat(exception.getMessage()).contains("File size exceeds the limit."); assertThat(exception).isNotSameAs(originalException); } diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md index 245c43c3..61c00e10 100644 --- a/doc/CHANGELOG.md +++ b/doc/CHANGELOG.md @@ -6,6 +6,11 @@ This project adheres to [Semantic Versioning](http://semver.org/). The format is based on [Keep a Changelog](http://keepachangelog.com/). +## Version 1.3.3 - 2026-03-15 + +### Fixed +- Fixed @Validation.Maximum error message not showing in consuming projects due to messages.properties being overwritten instead of merged. Error messages are now temporary self-contained and no longer rely on a resource bundle. + ## Version 1.3.2 - 2026-03-10 ### Fixed diff --git a/pom.xml b/pom.xml index 718841d9..611b6ae0 100644 --- a/pom.xml +++ b/pom.xml @@ -58,7 +58,7 @@ - 1.4.0-SNAPSHOT + 1.3.3-SNAPSHOT 17 ${java.version} UTF-8 diff --git a/samples/bookshop/pom.xml b/samples/bookshop/pom.xml index 21d13dfb..ce37d9cf 100644 --- a/samples/bookshop/pom.xml +++ b/samples/bookshop/pom.xml @@ -48,7 +48,7 @@ com.sap.cds cds-feature-attachments - 1.3.2 + 1.3.3