Fix approved admin alerts getting stuck as broadcasting in production - #404
Open
soroush5 wants to merge 1 commit into
Open
Fix approved admin alerts getting stuck as broadcasting in production#404soroush5 wants to merge 1 commit into
soroush5 wants to merge 1 commit into
Conversation
_create_p1_zendesk_alert assumed areas['names'], but admin-created
alerts store areas as {'ids': [...], 'simple_polygons': [...]}, so
approving one in prod raised KeyError AFTER the BROADCASTING status
was saved but BEFORE the broadcast event/task was created - the
alert was stuck as broadcasting and never sent, with retry blocked.
Also make the empty-areas approval check tolerate a missing
'simple_polygons' key (clean 400 instead of KeyError 500).
soroush5
force-pushed
the
fix/approve-admin-areas-zendesk-keyerror
branch
from
September 9, 2026 16:10
5dde5ca to
c2d649a
Compare
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.
Approving an admin-created alert in production crashed with
KeyError: 'names'after the status had already been saved asbroadcasting— so the alert looked broadcast but_create_broadcast_eventnever ran and nothing was ever sent. Retrying is impossible (broadcasting → broadcastingis not an allowed transition), so the alert was silently lost.Root cause:
_create_p1_zendesk_alertassumedareas["names"], but admin-created alerts store areas as{"ids": [...], "simple_polygons": [...]}— only API-created alerts have"names". The zendesk step runs afterdao_save_objectand before_create_broadcast_event, and only in production (is_prod), which is why no test ever caught it.This accepts both shapes in the ticket text, and also makes the empty-areas validation use
.get()so migrated{}rows get a clean 400 instead ofKeyError: 'simple_polygons'(500).Testing
tests/app/broadcast_message/test_utils.py(admin-shaped approve on prod, empty-areas 400). Full pytest needs a live postgres plus the shared utils package, unavailable here — verified the fix by executing the real module path and bypy_compile; flake8/black/isort clean.