Skip to content

Enhance ARI retry handling and improve webhook exception management#1184

Merged
shibayan merged 4 commits into
masterfrom
fix-ari-replaces
Jul 1, 2026
Merged

Enhance ARI retry handling and improve webhook exception management#1184
shibayan merged 4 commits into
masterfrom
fix-ari-replaces

Conversation

@shibayan

@shibayan shibayan commented Jul 1, 2026

Copy link
Copy Markdown
Member

This pull request improves the robustness and reliability of ACME order handling and webhook delivery in the application. It introduces enhanced error handling for ACME order replacements, ensures webhook notifications do not throw on failure, and adds comprehensive tests for these scenarios.

ACME order handling improvements:

  • Added logic in CreateOrderAsync to detect when an ACME order replacement has already been consumed (using the new IsAlreadyReplaced property on AcmeProtocolException). If this occurs, the order is retried without the replaces hint, and a warning is logged. (src/Acmebot.Acme/AcmeProtocolException.cs [1] src/Acmebot.App/Functions/Orchestration/AcmeOrderActivities.cs [2] [3]
  • Added a unit test to verify that when an ACME order fails with "already replaced," the code retries without the replaces field. (tests/Acmebot.App.Tests/AcmeOrderActivitiesTests.cs tests/Acmebot.App.Tests/AcmeOrderActivitiesTests.csR1-R162)

Webhook notification reliability:

  • Refactored WebhookInvoker to use a payload factory and to catch and log any exceptions during webhook delivery, ensuring that failures or exceptions do not cause the orchestration to fail. (src/Acmebot.App/Notifications/WebhookInvoker.cs [1] [2]
  • Added tests to ensure that webhook notification failures and payload builder exceptions are handled gracefully (do not throw). (tests/Acmebot.App.Tests/WebhookInvokerTests.cs tests/Acmebot.App.Tests/WebhookInvokerTests.csR1-R116)

Fixes #1183

shibayan added 2 commits July 1, 2026 15:59
Add support for detecting ACME `alreadyReplaced` protocol errors and retry order creation without the ARI `replaces` hint when that race condition occurs. Webhook delivery is also hardened by wrapping payload creation and HTTP posting in exception handling, logging warnings instead of letting failures bubble. New unit tests cover both the ACME retry behavior and non-throwing webhook failure paths.
Add UTF-8 BOM markers to two test source files so their encoding matches project/editor defaults and avoids inconsistent file-header diffs.
@shibayan shibayan self-assigned this Jul 1, 2026
Copilot AI review requested due to automatic review settings July 1, 2026 07:00
@shibayan shibayan added the bug Something isn't working label Jul 1, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This pull request improves resiliency in two places: ACME order creation when ARI “replaces” is rejected as alreadyReplaced, and webhook delivery so failures don’t crash orchestration.

Changes:

  • Adds AcmeProtocolException.IsAlreadyReplaced and retries order creation without replaces when that problem occurs.
  • Refactors WebhookInvoker to build payloads via a factory and swallow/log exceptions during webhook delivery.
  • Adds unit tests covering the ARI retry fallback and webhook failure/exception handling.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/Acmebot.Acme/AcmeProtocolException.cs Adds a convenience property to detect the alreadyReplaced ACME problem type.
src/Acmebot.App/Functions/Orchestration/AcmeOrderActivities.cs Adds retry logic for alreadyReplaced by reissuing the order without ARI replaces.
src/Acmebot.App/Notifications/WebhookInvoker.cs Ensures webhook payload creation and delivery exceptions are caught and logged (no orchestration failure).
tests/Acmebot.App.Tests/AcmeOrderActivitiesTests.cs Verifies alreadyReplaced causes a retry without replaces in the second POST.
tests/Acmebot.App.Tests/WebhookInvokerTests.cs Verifies webhook failures and payload builder exceptions do not throw.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/Acmebot.App.Tests/WebhookInvokerTests.cs
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 1, 2026 07:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings July 1, 2026 07:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

@shibayan shibayan merged commit 4dee761 into master Jul 1, 2026
11 checks passed
@shibayan shibayan deleted the fix-ari-replaces branch July 1, 2026 07:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ARI alreadyReplaced error not caught in Order activity, causes renewal loop

2 participants