Commit 5c42d2c
bgagent
fix(fanout): generalize Slack dedup to cover agent_error + log Retry-After (aws-samples#79 review aws-samples#4)
PR aws-samples#79 review aws-samples#4 surfaced a sibling-channel-failure hazard: when
GitHub or Email rate-limits, the record lands in
``batchItemFailures``. On the Lambda retry, every Slack-subscribed
event for that record runs again. Terminal events were already
guarded by ``slack_notified_terminal``; ``agent_error`` was not —
operators would page twice on a single agent failure if a sibling
channel happened to fail.
Generalize the dedup mechanism. ``TERMINAL_EVENTS`` is replaced by
a ``SLACK_DEDUP_ATTRIBUTE`` map that marks each event type with the
``channel_metadata`` attribute that should guard the post:
- 5 terminals share ``slack_notified_terminal`` (any first-arriving
terminal claims the right; subsequent terminals dedup against it)
- ``agent_error`` gets its own ``slack_dispatched_agent_error``
so a duplicate agent_error doesn't reuse the terminal slot
- ``task_created`` / ``session_started`` map to ``null`` because
they already use the per-event ``slack_*_msg_ts`` conditional
persists from review #1 — the conditional already provides
full idempotency (a separate marker would be redundant)
Also surfaces Slack's ``Retry-After`` header on rate-limited
responses through a dedicated ``fanout.slack.retryable_api_error``
warn so operators reading CloudWatch can see the recovery window
instead of guessing from sustained warn rate.
Tests:
- logs Retry-After header on rate-limited Slack responses (new):
asserts ``retry_after_seconds`` propagates from Slack's response
header into the warn metadata
- existing terminal-codes parametrized test untouched (terminal
branch doesn't read headers)
- existing retryable test gains a ``headers: { get: () => null }``
stub on the fetch mock so the headers.get call doesn't crash
Reviewer suggested a per-channel dispatch bitmap as the alternative.
Rejected as premature: the duplicate-GitHub-PATCH is harmless
(idempotent), Email is still a stub, and the dedup map covers
the specific agent_error pain identified above. A bitmap would add
a new table + IAM grants + per-dispatch DDB cost for a hypothetical
problem (Slack rate-limiting AND a sibling channel failure).1 parent b7bc393 commit 5c42d2c
2 files changed
Lines changed: 92 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
70 | 96 | | |
71 | 97 | | |
72 | 98 | | |
| |||
207 | 233 | | |
208 | 234 | | |
209 | 235 | | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
214 | 247 | | |
215 | 248 | | |
216 | 249 | | |
217 | 250 | | |
218 | | - | |
219 | | - | |
| 251 | + | |
| 252 | + | |
220 | 253 | | |
221 | 254 | | |
222 | 255 | | |
223 | 256 | | |
224 | | - | |
| 257 | + | |
225 | 258 | | |
226 | 259 | | |
227 | 260 | | |
| 261 | + | |
228 | 262 | | |
229 | 263 | | |
230 | 264 | | |
| |||
296 | 330 | | |
297 | 331 | | |
298 | 332 | | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
299 | 346 | | |
300 | 347 | | |
301 | 348 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
193 | 193 | | |
194 | 194 | | |
195 | 195 | | |
| 196 | + | |
196 | 197 | | |
197 | 198 | | |
198 | 199 | | |
| |||
207 | 208 | | |
208 | 209 | | |
209 | 210 | | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
210 | 248 | | |
211 | 249 | | |
212 | 250 | | |
| |||
0 commit comments