Skip to content

Conversation

@onbuyuka
Copy link
Contributor

@onbuyuka onbuyuka commented Jan 29, 2026

Problem

When disabling a Shopify shop or deleting a shop/company, if the webhook subscription cannot be deleted in Shopify (e.g., due to invalid API credentials, network issues, or the store being disconnected), the operation would fail with an error like:

Error(s) on Shopify:
"[API] Invalid API key or access token (unrecognized login or wrong password)"

This blocked users from disabling or deleting shops even when the Shopify store was already disconnected or inaccessible.

Root Cause

The DeleteWebhookSubscription function was being called directly, which throws an error if the Shopify API call fails. Additionally, even when using a [TryFunction] wrapper, there were two issues:

  1. TryFunction return value not used: In AL, if a TryFunction's return value isn't consumed, it behaves like a regular method and errors are still raised to the user.

  2. Database writes inside TryFunction: The ExecuteGraphQL function writes to the log table, which is not allowed inside a TryFunction when called from certain contexts (like page triggers).

Solution

  1. Created a new wrapper codeunit "Shpfy Delete Webhook Subs." (ID 30458) that uses the Codeunit.Run() pattern instead of [TryFunction]. This pattern:

    • Catches and suppresses errors (returns false on failure)
    • Allows database write transactions inside the executed code
  2. Updated TryDeleteWebhookSubscription to use this codeunit pattern and return a Boolean result.

  3. Updated callers in ShpfyWebhooksMgt to properly consume the return value with if ... then; syntax.

Work Item(s)

AB#619586

@github-actions github-actions bot added the AL: Apps (W1) Add-on apps for W1 label Jan 29, 2026
@github-actions github-actions bot added this to the Version 28.0 milestone Jan 29, 2026
@onbuyuka onbuyuka marked this pull request as ready for review January 29, 2026 23:49
@onbuyuka onbuyuka requested a review from a team as a code owner January 29, 2026 23:49
@onbuyuka onbuyuka enabled auto-merge (squash) February 2, 2026 10:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AL: Apps (W1) Add-on apps for W1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants