Refactor error messages for attachment size limit exceeded#756
Refactor error messages for attachment size limit exceeded#756Schmarvinius merged 4 commits intomainfrom
Conversation
There was a problem hiding this comment.
This PR replaces message-key-based ServiceException construction with hard-coded English strings and removes messages.properties, which breaks i18n support for the attachment size exceeded error — end users with non-English locales will always receive English error text. The rest of the changes (test assertions updated to match the new literal strings) are consistent, but the root approach needs reconsideration.
PR Bot Information
Version: 1.18.5 | 📖 Documentation | 🚨 Create Incident | 💬 Feedback
- Correlation ID:
18bff170-209e-11f1-8b74-13d94f6f6bc2 - LLM:
anthropic--claude-4.6-sonnet - Event Trigger:
pull_request.opened
| ExtendedErrorStatuses.CONTENT_TOO_LARGE, | ||
| "File size exceeds the limit of {}.", | ||
| maxSizeStr); |
There was a problem hiding this comment.
Best Practice: Hard-coded error message strings are not localizable
The old approach used a message key ("AttachmentSizeExceeded") looked up from messages.properties, which allowed the CAP framework to resolve the message from locale-specific bundles (e.g. i18n_de.properties). Replacing this with hard-coded English strings in all three throw sites (CreateAttachmentsHandler, ModifyApplicationHandlerHelper, CountingInputStream) and deleting messages.properties removes i18n support for this error message. End users who have a non-English locale will now always see the English text.
Consider adding the message key(s) to the existing CDS i18n bundle (_i18n/i18n.properties) and using a message key reference instead of a literal string, consistent with how the framework resolves other user-facing messages:
# in _i18n/i18n.properties
AttachmentSizeExceeded=File size exceeds the limit of {0}.
AttachmentSizeExceededNoLimit=File size exceeds the limit.Then use the key in the ServiceException constructor:
throw new ServiceException(
ExtendedErrorStatuses.CONTENT_TOO_LARGE,
"AttachmentSizeExceeded",
maxSizeStr);Please provide feedback on the review comment by checking the appropriate box:
- 🌟 Awesome comment, a human might have missed that.
- ✅ Helpful comment
- 🤷 Neutral
- ❌ This comment is not helpful
Refactor: Replace Message Keys with Inline Error Messages for Attachment Size Limit
♻️ Refactor: Replaced symbolic message key references (
AttachmentSizeExceeded) with descriptive inline error message strings for attachment size limit exceeded errors, and removed the now-unusedmessages.propertiesresource file.Changes
CreateAttachmentsHandler.java: Replaced"AttachmentSizeExceeded"message key with inline messages"File size exceeds the limit of {}."(with max size) and"File size exceeds the limit."(without max size) in therestoreErrormethod.ModifyApplicationHandlerHelper.java: Replaced"AttachmentSizeExceeded"message key with the inline message"File size exceeds the limit of {}."when constructing thetooLargeException.CountingInputStream.java: Replaced"AttachmentSizeExceeded"message key with the inline message"File size exceeds the limit of {}."in thecheckLimitmethod.messages.properties: Removed the file entirely as message keys are no longer used.CreateAttachmentsHandlerTest.java: Updated test assertions to match the new inline error message strings instead of the old message key references.📬 Subscribe to the Hyperspace PR Bot DL to get the latest announcements and pilot features!
PR Bot Information
Version:
1.18.5| 📖 Documentation | 🚨 Create Incident | 💬 Feedback18bff170-209e-11f1-8b74-13d94f6f6bc2anthropic--claude-4.6-sonnetpull_request.opened