fix: return structured errors instead of raising in apns_async bulk send#795
Open
fix: return structured errors instead of raising in apns_async bulk send#795
Conversation
…in `apns_async` When sending bulk APNS notifications, a single device failure would raise an exception and disrupt the entire batch. This made it impossible to: - Track which notifications succeeded vs failed - Properly handle partial failures at scale - Clean up only the failed registration IDs Now `apns_send_bulk_message` returns `BulkNotificationResult` containing: - `results`: dict mapping registration_id to success/failure status - `errors`: list of error objects with registration_id, error_type, error_message, and timestamp - `has_errors`: simple attribute to check if the batch operation raised an error and handle it properly in your code. This allows graceful degradation where one bad token doesn't kill thousands of successful notifications. Refs #750
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #795 +/- ##
==========================================
- Coverage 73.02% 64.28% -8.75%
==========================================
Files 31 31
Lines 1294 1288 -6
Branches 215 215
==========================================
- Hits 945 828 -117
- Misses 301 415 +114
+ Partials 48 45 -3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
When sending notifications to thousands of devices, a single unregistered token would raise an exception and stop the entire batch. The
resultsdict (containing success/failure info for each device) was lost, making it impossible to track which notifications actually succeeded.This forced developers into perpetual try/except blocks and prevented proper cleanup of invalid tokens.
Solution
BulkNotificationResultwith bothresultsanderrorsregistration_id: The device token that failederror_type: The specific error (e.g., "Unregistered", "BadDeviceToken")error_message: Descriptive error messagetimestamp: When the error was capturedCloses #750 (part 2 of 2)
cc @valhallen13 @igor-wl @s4cha