orderEditRemoveDiscount causes internal error

Internal error. Looks like something went wrong on our end.\nRequest ID: da6ddc80-76b3-43cc-8908-03e2bc886f73-1749428925 (include this in support requests).

I’m getting this when trying the orderEditRemoveLineItemDiscount and orderEditRemoveDiscount mutation. It only occurs when I include stagedChanges.

1 Like

Hey @Nicholas_Potts, thanks for sharing that.

Can you share more details about the steps I can take to replicate (specific mutations leading up to the error)? I’d like to try and replicate on my end.

Its extremely easy.

Create an order with an item. Apply a manual discount to the line item. Then try remove this manual discount:

mutation {
  orderEditRemoveDiscount(
    id: "gid://shopify/CalculatedOrder/99990896864"
    discountApplicationId: "gid://shopify/CalculatedManualDiscountApplication/2895897559264"
  ) {
    calculatedOrder {
      stagedChanges(first: 1) {
        nodes {
          __typename
        }
      }
    }
  }
}

By including stagedChanges, you’ll cause the mutation to error. It happens every time.

Thanks for the steps! I followed your exact workflow to try and reproduce this issue. Here’s what I tested:

  1. Started an order edit session with orderEditBegin
  2. Added a manual discount using orderEditAddLineItemDiscount with both fixed amount and percentage discounts
mutation {
  orderEditAddLineItemDiscount(
    id: "gid://shopify/CalculatedOrder/117678080022"
    discount: {
      fixedValue: { amount: "5.00", currencyCode: USD }
      description: "Test manual discount"
    }
    lineItemId: "gid://shopify/CalculatedLineItem/39350891905046"  
  ) {
    calculatedOrder {
      addedDiscountApplications(first: 10) {
        nodes {
          ... on CalculatedManualDiscountApplication {
            id  # This returned: gid://shopify/CalculatedManualDiscountApplication/365cfd82-222c-46ac-801d-fd0152f477f2
          }
        }
      }
    }
  }
}
  1. Attempted to remove the discount using your exact mutation structure:
mutation {
  orderEditRemoveDiscount(
    id: "gid://shopify/CalculatedOrder/117678080022"
    discountApplicationId: "gid://shopify/CalculatedManualDiscountApplication/365cfd82-222c-46ac-801d-fd0152f477f2"
  ) {
    calculatedOrder {
      stagedChanges(first: 1) {
        nodes {
          __typename
        }
      }
    }
    userErrors {
      field
      message
    }
  }
}

This executed successfully without internal errors. I notice you’re using a numeric discount application ID (2895897559264) while mine came back as a UUID format. Can you try creating the discount using like I did above and see if you get the UUID format and then see if that resolves the internal error when removing it?

I believe it has to be a discount that’s already committed. I’ll come back with exact reproduction steps.

These exact steps cause it. Simply a committed discount cannot be removed with the staged changes node.

mutation OrderEditBegin {
  orderEditBegin(id: "gid://shopify/Order/6161090576608") {
    calculatedOrder {
      id
      lineItems(first: 1) {
        nodes {
          id
        }
      }
    }
  }
}

mutation ApplyDiscount {
  orderEditAddLineItemDiscount(
    id: "gid://shopify/CalculatedOrder/100151165152"
    lineItemId: "gid://shopify/CalculatedLineItem/15106662564064"
    discount: {percentValue: 10}
  ) {
    calculatedOrder {
      id
    }
  }
}

mutation Commit {
  orderEditCommit(id:  "gid://shopify/CalculatedOrder/100151165152") {
    order {
      id
    }
  }
}

mutation OrderEditBeginDiscount {
  orderEditBegin(id: "gid://shopify/Order/6161090576608") {
    calculatedOrder {
      id
      lineItems(first: 1) {
        nodes {
          calculatedDiscountAllocations {
            discountApplication {
              id
            }
          }
        }
        
      }
    }
  }
}

mutation RemoveDiscount {
  orderEditRemoveDiscount(
    id: "gid://shopify/CalculatedOrder/100151197920"
    discountApplicationId: "gid://shopify/CalculatedManualDiscountApplication/2897674797280"
  ) {
    calculatedOrder {
      id
      stagedChanges(first: 1) { # this causes internal error
        nodes {
          __typename
        }
      }
    }
  }
}

Hey Nicholas, thanks for clarifying that.

When I test am now able to reproduce. I have noticed though that the removal is actually working when the error is returned.

I also noticed adding the various union types doesn’t change this and I get an error querying the calculated order directly.

So it does appear to be specific to the stagedChanges field only with discount removals.

Next steps here are I’ll consult with our dev teams to see why this specific change leads to an error.

Update here. I can confirm that this is an issue our team is aware of. I’ll keep an eye on it and update you here when I can.

Appreciate the update. I’m aware it does work despite erroring, unfortunately I do need the latest staged changes for my logic. I have a workaround in the meantime but I look forward to an update.