Skip to content

fix(webhooks): stop reporting failed deliveries as platform errors - #14558

Merged
ChiragAgg5k merged 2 commits into
mainfrom
fix/webhook-delivery-unpublished
Oct 15, 2026
Merged

ChiragAgg5k merged 2 commits into
mainfrom
fix/webhook-delivery-unpublished

Conversation

@ChiragAgg5k

@ChiragAgg5k ChiragAgg5k commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

A webhook receiver that fails (DNS, timeout, 5xx) made the worker throw a plain Exception. Error reporting publishes code-0 exceptions, so every broken customer endpoint showed up as a platform error.

// before
throw new Exception(\implode(" / \n\n", $errors));

// after: still redelivered and logged, just not published
throw new AppwriteException(AppwriteException::WEBHOOK_DELIVERY_FAILED, \implode(" / \n\n", $errors));

webhook_delivery_failed is 502, 'publish' => false. Retries are unchanged: only PermanentFailure/TypeError/ValueError skip redelivery.

Tests: the retry half is covered by the existing e2e WebhooksBase::testRedeliveryRetriesOnlyTheWebhookThatFailed, which fails a delivery and asserts it is redelivered. There is no e2e for the "not published" half: the compose stack runs no error-reporting sink to assert against.

Related: appwrite-labs/cloud#5938

A receiver that is down or does not resolve made the worker throw a plain Exception, which the error exporter publishes. Throw an unpublished webhook_delivery_failed instead: the broker still redelivers the event and the failure is still logged, but it no longer alerts.
@luxor-code-review

luxor-code-review Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Review complete. No issues found.


The change replaces the generic thrown exception in the webhooks worker partial-failure path with a dedicated WEBHOOK_DELIVERY_FAILED error code (502) marked publish=false, adds the constant to Appwrite\Extend\Exception, and covers the retry-without-publish behavior with a new unit test.

Files Change
src/Appwrite/Platform/Workers/Webhooks.php Throws the new dedicated exception type when one or more deliveries fail after retries.
app/config/errors.php, src/Appwrite/Extend/Exception.php Registers the WEBHOOK_DELIVERY_FAILED error code with publish=false and its exception constant.
tests/unit/Platform/Workers/WebhooksTest.php Adds a test asserting failed deliveries are retried and logged without being published as alerts.

Two low-severity observations fell below the review confidence threshold: the new unit test drives the worker action directly with real network I/O, which project guidance reserves for e2e suites, and the thrown error message aggregates up to 10KB of receiver-controlled body per failing webhook without applying APP_LOG_LENGTH_LIMIT.

Reviewed commit: 300787e

@ghost

ghost commented Oct 15, 2026

Copy link
Copy Markdown

🔵 Tier A · Mergeable after minor fixes

The delivery error change looks correct, but the new worker-action test conflicts with the repository's explicit unit-test guidance.

Adds a dedicated unpublished 502 error for failed webhook deliveries while preserving the worker's existing redelivery path. Adds a regression test that exercises a failed delivery and checks the persisted attempt count and logs.

Verdict New comments Fixed Still open
✅ Approved 1 0 0
Finding Where
🟡 Keep worker action coverage out of the unit suite tests/unit/Platform/Workers/WebhooksTest.php:226
Fix with agent prompt
### Issue 1
tests/unit/Platform/Workers/WebhooksTest.php:226
**Keep worker action coverage out of the unit suite**

This directly exercises `Webhooks::action()` in a unit test, but the Tests guidance in `AGENTS.md` says workers are covered by e2e and should not be unit-tested. Please move this worker-surface coverage to the appropriate integration/e2e suite; the unit suite should cover the libraries the worker calls.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
📂 Walkthrough · 4
File Change
app/config/errors.php Registers the new webhook delivery error as HTTP 502 and unpublished.
src/Appwrite/Extend/Exception.php Adds the webhook delivery failure error type.
src/Appwrite/Platform/Workers/Webhooks.php Throws the new typed error after recording successful webhook deliveries for redelivery.
tests/unit/Platform/Workers/WebhooksTest.php Adds coverage for failed webhook delivery state and the thrown error.

Reviewed 300787e · Details · Comment @hansi-codes review to re-run, or mention @hansi-codes with a question.

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Tier A · Looks good to merge. Summary

@ChiragAgg5k ChiragAgg5k self-assigned this Oct 15, 2026
@github-actions

Copy link
Copy Markdown

Security rules

No new WARNING or ERROR findings from security rules.

19 existing findings tracked in .semgrep/baseline.json
  • php.appwrite.guest-write-without-abuse-limit (12)
  • php.appwrite.secret-compare-timing (5)
  • php.appwrite.weak-secret-env-default (2)

Posted by Checks / Rules. Re-runs update this comment in place. Rule details and baseline: .semgrep/README.md.

@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → fix/webhook-delivery-unpublished (after).

Metric Before After Change
🚀 Requests/sec 195.14 205.24 🟢 +5.2%
⏱️ Latency P50 86.91 ms 85.4 ms ⚪ -1.7%
⏱️ Latency P95 209.15 ms 194.46 ms 🟢 -7%
Per-scenario breakdown & investigation details

Metrics below reflect the current branch (after). Δ P95 compares against the base.

Scenario P50 (ms) P95 (ms) Requests RPS Δ P95 (ms)
API total 85.4 194.46 12,654 205.24 -14.69
Account 161.46 285.21 666 11.02 -29.36
TablesDB 82.71 150.6 6,882 112.9 -7.95
Storage 80.32 182.3 3,330 56.77 -15.02
Functions 117.26 224.83 1,776 31.01 -26.64

Top API waits (after)

API request Max wait (ms)
account.name.update 421.14
functions.create 376.29
tablesdb.rows.delete 359.5
tablesdb.rows.increment 354.4
account.prefs.update 329.97

@ChiragAgg5k
ChiragAgg5k merged commit 7bff59f into main Oct 15, 2026
65 checks passed
@ChiragAgg5k
ChiragAgg5k deleted the fix/webhook-delivery-unpublished branch October 15, 2026 12:58
@ChiragAgg5k ChiragAgg5k mentioned this pull request Oct 21, 2026
6 tasks
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.

1 participant