MM-68364: Truncate oversized GitHub plugin DM posts to avoid silent drops#1003
MM-68364: Truncate oversized GitHub plugin DM posts to avoid silent drops#1003
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR adds message truncation to bot direct messages. When a bot DM exceeds ChangesMessage Truncation for Bot DMs
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
avasconcelos114
left a comment
There was a problem hiding this comment.
Great improvement 👍 👍
Summary
This PR truncates the message body in the central
CreateBotDMPosthelper before sending. The cap usesmodel.PostMessageMaxRunesV2to preserve UTF-8 boundaries and truncated messages get a_… message truncated_marker so users know to check GitHub for the full content.Ticket Link
https://mattermost.atlassian.net/browse/MM-68364
Change Impact: 🟡 Medium
Reasoning: The change introduces truncation logic to a widely-used central utility function (
CreateBotDMPost) that handles GitHub webhook notifications and event-triggered DM messages. While the modification is backward-compatible and well-tested, its broad usage across notification flows and potential impact on user-facing messaging necessitates medium-level scrutiny.Regression Risk: Low-to-Medium. The truncation logic only activates when messages exceed
model.PostMessageMaxRunesV2; shorter messages pass through unchanged. The function signature remains identical, so callers are unaffected. However, the change affects every DM post created by the plugin (webhook notifications, account management notifications, API responses), and incorrect truncation or UTF-8 boundary violations could silently alter message content. The new test coverage fortruncatePostMessagemitigates this with explicit tests for multibyte characters and rune boundary preservation.QA Recommendation: Manual testing should verify that: (1) oversized GitHub webhook messages (e.g., long issue descriptions, PR review comments) are properly truncated with the marker and remain readable, (2) multibyte UTF-8 characters (emojis, non-Latin scripts) are not corrupted during truncation, and (3) normal-sized messages are unaffected. Automated test coverage is good; manual QA can be brief and focused on message boundary cases. Rollback risk is low due to backward compatibility.