Skip to content

Refactor error messages for attachment size limit exceeded#756

Merged
Schmarvinius merged 4 commits intomainfrom
temp_solution_for_message
Mar 15, 2026
Merged

Refactor error messages for attachment size limit exceeded#756
Schmarvinius merged 4 commits intomainfrom
temp_solution_for_message

Conversation

@Schmarvinius
Copy link
Collaborator

@Schmarvinius Schmarvinius commented Mar 15, 2026

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-unused messages.properties resource 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 the restoreError method.
  • ModifyApplicationHandlerHelper.java: Replaced "AttachmentSizeExceeded" message key with the inline message "File size exceeds the limit of {}." when constructing the tooLargeException.
  • CountingInputStream.java: Replaced "AttachmentSizeExceeded" message key with the inline message "File size exceeds the limit of {}." in the checkLimit method.
  • 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.
  • 🔄 Regenerate and Update Summary

📬 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 | 💬 Feedback

  • Correlation ID: 18bff170-209e-11f1-8b74-13d94f6f6bc2
  • LLM: anthropic--claude-4.6-sonnet
  • Output Template: Default Template
  • Summary Prompt: Default Prompt
  • Event Trigger: pull_request.opened

Copy link
Contributor

@hyperspace-insights hyperspace-insights bot left a comment

Choose a reason for hiding this comment

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

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

Comment on lines +85 to +87
ExtendedErrorStatuses.CONTENT_TOO_LARGE,
"File size exceeds the limit of {}.",
maxSizeStr);
Copy link
Contributor

Choose a reason for hiding this comment

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

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

@Schmarvinius Schmarvinius merged commit 2a26224 into main Mar 15, 2026
12 checks passed
@Schmarvinius Schmarvinius deleted the temp_solution_for_message branch March 15, 2026 18:54
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