Bug: Storefront API quantityAvailable with @inContext(country:) returns global negative total for all countries when net across locations is negative

When a variant’s combined available across all locations drops below 0, the Storefront API returns the same negative, global total for quantityAvailable for every @inContext(country: …) request—instead of returning the country-scoped availability for the locations that serve that market. This works correctly while the global net is ≥ 0 and breaks only when the global net is < 0.

This causes incorrect availability on international storefronts that rely on country context.

Environment

  • API: Storefront API (GraphQL)

  • Query: @inContext(country: XX)ProductVariant.quantityAvailable (and availableForSale)

  • Markets / Locations: AU, US, CA mapped to distinct locations/fulfillment networks

  • Screenshots provided

Data Setup (from Admin > Inventory)

Scenario A (works as expected):

  • AU location: 69 available

  • US location: 4 available

  • CA location: 9 available

  • Global total: +82

Scenario B (bug):

  • AU location: 69 available

  • US location: -100 available (oversell/negative adjustment)

  • CA location: 9 available

  • Global total: -22

Reproduction (Storefront API)

Query (run 3 times with different country):

query VariantQty($variantId: ID!) @inContext(country: AU) {
  node(id: $variantId) {
    ... on ProductVariant {
      id
      availableForSale
      quantityAvailable
    }
  }
}

Repeat exactly with country: US and country: CA.

Expected

  • With Scenario A (global ≥ 0)

    • country: AUquantityAvailable = 69

    • country: USquantityAvailable = 4

    • country: CAquantityAvailable = 9

  • With Scenario B (global < 0)

    • country: AUquantityAvailable = 69

    • country: USquantityAvailable = -100 or 0 (if negatives are clamped for sellable quantity)

    • country: CAquantityAvailable = 9

Actual (Scenario B when Total is -22)

  • country: AUquantityAvailable = -22

  • country: USquantityAvailable = -22

  • country: CAquantityAvailable = -22

In other words, when the global net across all locations is negative, every @inContext(country:) call returns the same global negative number for quantityAvailable, ignoring country/location scoping.

Impact

  • Country-specific PDPs show the same negative availability regardless of market, which:

    • Blocks sales in countries that do have stock (e.g., AU with 69 available).

    • Breaks channel/market routing that depends on @inContext.

  • Forces fragile client-side workarounds (clamping or re-implementing market scoping).

Severity: High for multi-market merchants using @inContext.

Notes / Hypothesis

  • The Storefront resolver for quantityAvailable appears to:

    1. Correctly scope to market while global net ≥ 0; but

    2. Fall back to a global sum (without market scoping) when the global sum < 0.

  • availableForSale follows the same faulty behavior (mirrors the incorrect negative/global result).

What we’re asking Shopify to confirm / fix

  1. Intended behavior: With @inContext(country: XX), quantityAvailable must reflect only the locations serving that country/market—even if the global sum is negative.

  2. Patch the Storefront resolver to avoid substituting the global negative sum for all country contexts.

Temporary Workarounds

  • Setting the inventory quantity to a number equal or greater than 0 for each location, but this is not ideal, and we shouldn’t have to do this, especially if we are committed to overselling when items are out of stock, or for other reasons.

  • The API should behave consistently.

  • I also must add that we are going live in 2 weeks and really need this issue resolved. Thanks!

anyone

Hi @Aaron_Brill,

Thank you very much for the detailed report of the behaviour you’ve shared, with specific details and examples, it’s very helpful!

I’ve looked into this behaviour further, and I have been able to replicate this on my own store, with the Storefront API returning the global total inventory values, instead of the contextualized market inventory values. However I’ve been able to replicate this in all instances on my own store, not just when the global inventory value is negative.

After further investigation, I have found this was an issue our developers are aware of and have done some further work in resolving this, however after applying the fix that was released for this on my test store, I’m still able to replicate the issue.

At this time I am currently discussing this with our developers internally to help look into this further, and I will be sure to follow up with you in the thread here once we have more information to share!

For the future, if you have an urgent issue or bug that is occurring on a store, we do recommend that you reach out via the Shopify Help Center and discuss it with our Shopify Support Team directly, to ensure it gets looked into as quickly as possible.

1 Like

Hi again @Aaron_Brill,

Just following up again after discussing this with our developers further.

I can confirm that a fix is being worked on for this, and should be released soon. If you’d like us to apply the fix to any specific stores early, please reach out to our support team via the Shopify Help Center, while logged into the store in question, and we can help get that accommodated.

Otherwise, we will be releasing a fix for all stores coming up soon, though we are unable to provide any estimated timeframes, and I will follow up here to let you know when that fix is fully released.

1 Like

Thank you @Kellan-Shopify ! Appreciate the follow-up, and please keep me posted.

-Aaron

Hi @Aaron_Brill,

it looks like the fix was actually released sooner than expected, and should be available on all stores moving forward!

To ensure that the contextualized inventory values are returned, you will need to make sure the Show only fulfillable inventory option is selected in the store’s Shipping Settings.

  1. Navigate to Setttings > Shipping and delivery
  2. Under the Shipping Profile section, click the Fulfillable Inventory link
  3. Check the box labeled Show only fulfillable inventory and Save

1 Like