Fiddle: truncate discord notifications to fit api#127
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds two independent enhancements: support for AWS session tokens in SQS queues and message truncation for Discord notifications.
- Added optional
sessionTokenparameter toSqsMessageQueuefor AWS session-based authentication - Implemented truncation logic in
DiscordClientto limit messages to 1000 characters - Updated changelog to document the Discord notification change
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| core/queues/sqs.py | Added optional sessionToken parameter and passed it to SQS client creation |
| core/notifications/discord_client.py | Added message truncation to 1000 characters with logging |
| CHANGELOG.md | Added entry for Discord message truncation feature |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+13
to
+15
| if len(messageText) > 1000: # noqa: PLR2004 | ||
| logging.info('Truncating Discord message to 1000 characters') | ||
| messageText = messageText[:997] + '...' |
There was a problem hiding this comment.
Discord webhooks actually support a content limit of 2000 characters, not 1000. The current implementation unnecessarily truncates messages at half the actual API limit. Consider updating the limit to 2000 characters and adjusting the truncation to messageText[:1997] + '...'.
Suggested change
| if len(messageText) > 1000: # noqa: PLR2004 | |
| logging.info('Truncating Discord message to 1000 characters') | |
| messageText = messageText[:997] + '...' | |
| if len(messageText) > 2000: # noqa: PLR2004 | |
| logging.info('Truncating Discord message to 2000 characters') | |
| messageText = messageText[:1997] + '...' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Screenshots:
Checklist: