Commit c2533d8
committed
fix: retry GitHub webhook delivery on 401 or missing secret
When a workflow is activated, n8n generates a new webhook secret in
staticData. If unihook's periodic refresh hasn't picked it up yet,
the first forward will fail (401 wrong HMAC, or no secret to sign with).
Changes:
- forward_event now returns the HTTP status code (Result<u16, ...>)
- forward_to_webhook returns Option<u16> for callers to inspect
- GitHubRouter::route_event implements a 3-phase retry:
1. Forward to all matching triggers, collecting results
2. Identify failures (401 or missing webhook secret)
3. Refresh trigger cache from n8n API and retry failed deliveries
- Fix nginx mock regex to allow empty owner/repo segments (n8n sends
POST /repos///hooks during initial workflow save)
- Add wiremock-based unit tests for retry logic:
- test_no_retry_when_all_forwards_succeed
- test_retry_on_401_refreshes_triggers_and_retries
- test_retry_on_missing_secret_refreshes_and_retries
Bump to v0.3.11 parent 0f6f17f commit c2533d8
5 files changed
Lines changed: 408 additions & 65 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
| 49 | + | |
48 | 50 | | |
49 | 51 | | |
50 | 52 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
| 150 | + | |
150 | 151 | | |
151 | 152 | | |
152 | 153 | | |
| |||
215 | 216 | | |
216 | 217 | | |
217 | 218 | | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
218 | 222 | | |
219 | 223 | | |
220 | 224 | | |
221 | 225 | | |
222 | 226 | | |
223 | | - | |
| 227 | + | |
224 | 228 | | |
225 | 229 | | |
226 | 230 | | |
| |||
249 | 253 | | |
250 | 254 | | |
251 | 255 | | |
252 | | - | |
253 | | - | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
254 | 260 | | |
255 | 261 | | |
256 | 262 | | |
257 | 263 | | |
258 | 264 | | |
259 | 265 | | |
260 | 266 | | |
261 | | - | |
| 267 | + | |
262 | 268 | | |
263 | 269 | | |
264 | 270 | | |
| |||
0 commit comments