undeterministic nature of cartMutation graphql call

Topic summary

A developer is experiencing inconsistent behavior with Shopify’s cartDiscountCodesUpdate GraphQL mutation from the Storefront API. The mutation sometimes successfully applies discount codes to the cart and sometimes fails, with no apparent pattern.

The developer notes that:

  • The official Shopify documentation doesn’t explain this non-deterministic behavior
  • They’re unsure how to troubleshoot or resolve the issue given its unpredictable nature

The discussion remains open with no responses yet, leaving the root cause and potential solutions unidentified. This appears to be a reliability issue with the Storefront API mutation that needs investigation.

Summarized with AI on November 1. AI used: claude-sonnet-4-5-20250929.

Hello guys,

When ever I am requesting this graphql storefront call

It’s yielding in non-deterministic behaviour, sometimes the discount is applied to the cart and sometimes not.
Not sure what’s the catch here
There is nothing written in the documentation as well about this behaviour,
If it’s indeed non-deterministic how do we even attempt to solve this

Thanks in advance.
https://shopify.dev/docs/api/storefront/2025-01/mutations/cartDiscountCodesUpdate

mutation cartDiscountCodesUpdate($cartId: ID!, $discountCodes: [String!]) {
cartDiscountCodesUpdate(cartId: $cartId, discountCodes: $discountCodes) {
cart {
id
}
}
}