Skip to content

Conversation

colinodell
Copy link
Member

@colinodell colinodell commented Jan 9, 2025

Currently, incoming webhooks will return an HTTP 4xx or 5xx error under any of these circumstances:

  1. The incoming payload is invalid
  2. The handler encountered an error trying to generate notifications from the payload
  3. Any of the notifications failed to deliver for any reason

This behavior seems ideal for scenarios 1 and 2, but not for 3. We should only return errors if the payload was malformed or we just couldn't handle it. Other cases (such as delivery failures in scenario 3) are not the webhook's fault and should therefore not be reported as errors to them. (We should instead of our own internal mechanisms to retry delivery, log failures, etc)

The current behavior in scenario 3 is especially problematic for senders like Argo CD, which will reattempt delivery of the webhook to Mailroom multiple times if it sees an HTTP 5xx response code.

Let's therefore change this behavior to:

  • Always return HTTP 202 Accepted whenever we successfully parse the payload and generate some pending notifications
  • Rely on Mailroom's error logging to indicate delivery failures instead of exposing errors to our callers

@colinodell colinodell self-assigned this Jan 9, 2025
Copy link

codecov bot commented Jan 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 77.77%. Comparing base (cac130a) to head (2a4cb2b).
Report is 1 commits behind head on main.

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #39      +/-   ##
==========================================
+ Coverage   77.75%   77.77%   +0.02%     
==========================================
  Files          20       20              
  Lines         980      981       +1     
==========================================
+ Hits          762      763       +1     
  Misses        205      205              
  Partials       13       13              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@colinodell colinodell requested review from zhammer and bbckr January 9, 2025 12:00
@colinodell colinodell merged commit d807c5e into main Jan 9, 2025
10 checks passed
@colinodell colinodell deleted the handler-responses branch January 9, 2025 12:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants