UPSTREAM FIX

magento2-39972: Error getting order item coupon code for customer order via GraphQl customer request

Community fix magento2-39972 merged into magento/magento2 on 2025-08-11, released in 2.4.9; applies cleanly to 33 releases from 2.4.6 to 2.4.8-p5.

Pull request title
Error getting order item coupon code for customer order via GraphQl customer request
Pull request
magento/magento2#39972
Issues
#39962 human
Author
@rogerdz
Merged
2025-08-11
Fixed in
2.4.9
Reported on
2.4.8
Categories
Catalog/Product, GraphQL, Price/Tax, Shopping Cart
Components
magento/module-sales-graph-ql

Labels

Area
Promotion Rules
Component
GraphQL
Priority
P2
Severity
—
Reported on (labels)
2.4.8

Issue

Title and steps come from the upstream issue and pull request.

Description

There is an error: "discount_model" value should be specified

Steps to reproduce

1. Create a simple product, customer, sales rule with a coupon, and place an order using this customer and applying coupon.
2. Get customer token via GraphQL query generateCustomerToken
3. Issue GraphQL request
query {
  customer {
    firstname
    lastname
    orders {
      items {
        order_number
        status
        items {
          product_sku
          discounts {
            coupon {
              code
            }
            amount {
              value
            }
          }
        }
      }
      page_info {
        current_page
        page_size
        total_pages
      }
      total_count
    } 
  }
}

Expected result

There is a correct response from GraphQl with orders and order items discount data

Actual result

There is an error: "discount_model" value should be specified

exception.log:
[2025-06-05T07:21:43.918952+00:00] main.ERROR: "discount_model" value should be specified

GraphQL (28:13)
27:           discounts {
28:             coupon {
                ^
29:               code
 {"exception":"[object] (GraphQL\\Error\\Error(code: 0): \"discount_model\" value should be specified at /home/zak/sites/magento/storefront/public/vendor/webonyx/graphql-php/src/Error/Error.php:155)
[previous exception] [object] (Magento\\Framework\\Exception\\LocalizedException(code: 0): \"discount_model\" value should be specified at /home/zak/sites/magento/storefront/public/vendor/magento/module-sales-rule-graph-ql/Model/Resolver/Coupon.php:40)"} []
[2025-06-05T07:21:43.919095+00:00] main.ERROR: Magento\Framework\Exception\LocalizedException: "discount_model" value should be specified in /home/zak/sites/magento/storefront/public/vendor/magento/module-sales-rule-graph-ql/Model/Resolver/Coupon.php:40
Stack trace:
#0 /home/zak/sites/magento/storefront/public/vendor/magento/framework/Interception/Interceptor.php(58): Magento\SalesRuleGraphQl\Model\Resolver\Coupon->resolve()
#1 /home/zak/sites/magento/storefront/public/vendor/magento/framework/Interception/Interceptor.php(138): Magento\SalesRuleGraphQl\Model\Resolver\Coupon\Interceptor->___callParent()
#2 /home/zak/sites/magento/storefront/public/vendor/magento/module-graph-ql-resolver-cache/Model/Plugin/Resolver/Cache.php(212): Magento\SalesRuleGraphQl\Model\Resolver\Coupon\Interceptor->Magento\Framework\Interception\{closure}()
#3 /home/zak/sites/magento/storefront/public/vendor/magento/module-graph-ql-resolver-cache/Model/Plugin/Resolver/Cache.php(128): Magento\GraphQlResolverCache\Model\Plugin\Resolver\Cache->executeResolver()
#4 /home/zak/sites/magento/storefront/public/vendor/magento/framework/Interception/Interceptor.php(135): Magento\GraphQlResolverCache\Model\Plugin\Resolver\Cache->aroundResolve()
#5 /home/zak/sites/magento/storefront/public/vendor/magento/framework/Interception/Interceptor.php(153): Magento\SalesRuleGraphQl\Model\Resolver\Coupon\Interceptor->Magento\Framework\Interception\{closure}()
#6 /home/zak/sites/magento/storefront/public/generated/code/Magento/SalesRuleGraphQl/Model/Resolver/Coupon/Interceptor.php(23): Magento\SalesRuleGraphQl\Model\Resolver\Coupon\Interceptor->___callPlugins()
#7 /home/zak/sites/magento/storefront/public/vendor/magento/framework/GraphQl/Query/Resolver/PromiseFactory.php(63): Magento\SalesRuleGraphQl\Model\Resolver\Coupon\Interceptor->resolve()
#8 /home/zak/sites/magento/storefront/public/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(714): Magento\Framework\GraphQl\Query\Resolver\PromiseFactory->Magento\Framework\GraphQl\Query\Resolver\{closure}()
#9 /home/zak/sites/magento/storefront/public/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(631): GraphQL\Executor\ReferenceExecutor->resolveFieldValueOrError()
#10 /home/zak/sites/magento/storefront/public/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(1317): GraphQL\Executor\ReferenceExecutor->resolveField()
#11 /home/zak/sites/magento/storefront/public/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(1256): GraphQL\Executor\ReferenceExecutor->executeFields()
#12 /home/zak/sites/magento/storefront/public/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(1210): GraphQL\Executor\ReferenceExecutor->collectAndExecuteSubfields()
#13 /home/zak/sites/magento/storefront/public/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(893): GraphQL\Executor\ReferenceExecutor->completeObjectValue()
#14 /home/zak/sites/magento/storefront/public/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(753): GraphQL\Executor\ReferenceExecutor->completeValue()
#15 /home/zak/sites/magento/storefront/public/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(985): GraphQL\Executor\ReferenceExecutor->completeValueCatchingError()
#16 /home/zak/sites/magento/storefront/public/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(871): GraphQL\Executor\ReferenceExecutor->completeListValue()
#17 /home/zak/sites/magento/storefront/public/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(753): GraphQL\Executor\ReferenceExecutor->completeValue()
#18 /home/zak/sites/magento/storefront/public/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(640): GraphQL\Executor\ReferenceExecutor->completeValueCatchingError()
#19 /home/zak/sites/magento/storefront/public/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(1317): GraphQL\Executor\ReferenceExecutor->resolveField()
#20 /home/zak/sites/magento/storefront/public/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(1256): GraphQL\Executor\ReferenceExecutor->executeFields()
#21 /home/zak/sites/magento/storefront/public/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(1210): GraphQL\Executor\ReferenceExecutor->collectAndExecuteSubfields()
#22 /home/zak/sites/magento/storefront/public/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(1074): GraphQL\Executor\ReferenceExecutor->completeObjectValue()
#23 /home/zak/sites/magento/storefront/public/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(888): GraphQL\Executor\ReferenceExecutor->completeAbstractValue()
#24 /home/zak/sites/magento/storefront/public/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php(750): GraphQL\Executor\ReferenceExecutor->completeValue()
#25 /home/zak/sites/magento/storefront/public/vendor/webonyx/graphql-php/src/Executor/Promise/Adapter/SyncPromise.php(152): GraphQL\Executor\ReferenceExecutor->GraphQL\Executor\{closure}()
#26 /home/zak/sites/magento/storefront/public/vendor/webonyx/graphql-php/src/Executor/Promise/Adapter/SyncPromise.php(50): GraphQL\Executor\Promise\Adapter\SyncPromise->GraphQL\Executor\Promise\Adapter\{closure}()
#27 /home/zak/sites/magento/storefront/public/vendor/webonyx/graphql-php/src/Executor/Promise/Adapter/SyncPromiseAdapter.php(144): GraphQL\Executor\Promise\Adapter\SyncPromise::runQueue()
#28 /home/zak/sites/magento/storefront/public/vendor/webonyx/graphql-php/src/GraphQL.php(108): GraphQL\Executor\Promise\Adapter\SyncPromiseAdapter->wait()
#29 /home/zak/sites/magento/storefront/public/vendor/magento/framework/GraphQl/Query/QueryProcessor.php(91): GraphQL\GraphQL::executeQuery()
#30 /home/zak/sites/magento/storefront/public/vendor/magento/module-graph-ql/Controller/GraphQl.php(202): Magento\Framework\GraphQl\Query\QueryProcessor->process()
#31 /home/zak/sites/magento/storefront/public/vendor/magento/framework/Interception/Interceptor.php(58): Magento\GraphQl\Controller\GraphQl->dispatch()
#32 /home/zak/sites/magento/storefront/public/vendor/magento/framework/Interception/Interceptor.php(138): Magento\GraphQl\Controller\GraphQl\Interceptor->___callParent()
#33 /home/zak/sites/magento/storefront/public/vendor/magento/module-page-cache/Model/App/FrontController/BuiltinPlugin.php(72): Magento\GraphQl\Controller\GraphQl\Interceptor->Magento\Framework\Interception\{closure}()
#34 /home/zak/sites/magento/storefront/public/vendor/magento/framework/Interception/Interceptor.php(135): Magento\PageCache\Model\App\FrontController\BuiltinPlugin->aroundDispatch()
#35 /home/zak/sites/magento/storefront/public/vendor/magento/framework/Interception/Interceptor.php(153): Magento\GraphQl\Controller\GraphQl\Interceptor->Magento\Framework\Interception\{closure}()
#36 /home/zak/sites/magento/storefront/public/generated/code/Magento/GraphQl/Controller/GraphQl/Interceptor.php(23): Magento\GraphQl\Controller\GraphQl\Interceptor->___callPlugins()
#37 /home/zak/sites/magento/storefront/public/vendor/magento/framework/App/Http.php(116): Magento\GraphQl\Controller\GraphQl\Interceptor->dispatch()
#38 /home/zak/sites/magento/storefront/public/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\App\Http->launch()
#39 /home/zak/sites/magento/storefront/public/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\App\Http\Interceptor->___callParent()
#40 /home/zak/sites/magento/storefront/public/vendor/magento/module-application-performance-monitor/Plugin/ApplicationPerformanceMonitor.php(38): Magento\Framework\App\Http\Interceptor->Magento\Framework\Interception\{closure}()
#41 /home/zak/sites/magento/storefront/public/vendor/magento/framework/Interception/Interceptor.php(135): Magento\ApplicationPerformanceMonitor\Plugin\ApplicationPerformanceMonitor->aroundLaunch()
#42 /home/zak/sites/magento/storefront/public/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\App\Http\Interceptor->Magento\Framework\Interception\{closure}()
#43 /home/zak/sites/magento/storefront/public/generated/code/Magento/Framework/App/Http/Interceptor.php(23): Magento\Framework\App\Http\Interceptor->___callPlugins()
#44 /home/zak/sites/magento/storefront/public/vendor/magento/framework/App/Bootstrap.php(264): Magento\Framework\App\Http\Interceptor->launch()
#45 /home/zak/sites/magento/storefront/public/pub/index.php(30): Magento\Framework\App\Bootstrap->run()
#46 {main} {"exception":"[object] (Magento\\Framework\\Exception\\LocalizedException(code: 0): \"discount_model\" value should be specified at /home/zak/sites/magento/storefront/public/vendor/magento/module-sales-rule-graph-ql/Model/Resolver/Coupon.php:40)"} []

Taken from the upstream issue.

Error signatures

Code match per tag

Each tag was checked with git apply --check against that tag's files. A clean match means the change applies; it is not a test result. Tags that already contain the fix are marked.

LineCode match per tagTests
2.4.6
2.4.6 clean 2.4.6-p1 clean 2.4.6-p2 clean 2.4.6-p3 clean 2.4.6-p4 clean 2.4.6-p5 clean 2.4.6-p6 clean 2.4.6-p7 clean 2.4.6-p8 clean 2.4.6-p9 clean 2.4.6-p10 clean 2.4.6-p11 clean 2.4.6-p12 clean 2.4.6-p13 clean 2.4.6-p14 clean 2.4.6-p15 clean
2.4.6: no test data 2.4.6-p1: no test data 2.4.6-p2: no test data 2.4.6-p3: no test data 2.4.6-p4: no test data 2.4.6-p5: no test data 2.4.6-p6: no test data 2.4.6-p7: no test data 2.4.6-p8: no test data 2.4.6-p9: no test data 2.4.6-p10: no test data 2.4.6-p11: no test data 2.4.6-p12: no test data 2.4.6-p13: no test data 2.4.6-p14: no test data 2.4.6-p15: no test data
2.4.7
2.4.7 clean 2.4.7-p1 clean 2.4.7-p2 clean 2.4.7-p3 clean 2.4.7-p4 clean 2.4.7-p5 clean 2.4.7-p6 clean 2.4.7-p7 clean 2.4.7-p8 clean 2.4.7-p9 clean 2.4.7-p10 clean
2.4.7: no test data 2.4.7-p1: no test data 2.4.7-p2: no test data 2.4.7-p3: no test data 2.4.7-p4: no test data 2.4.7-p5: no test data 2.4.7-p6: no test data 2.4.7-p7: no test data 2.4.7-p8: no test data 2.4.7-p9: no test data 2.4.7-p10: no test data
2.4.8
2.4.8 clean 2.4.8-p1 clean 2.4.8-p2 clean 2.4.8-p3 clean 2.4.8-p4 clean 2.4.8-p5 clean
2.4.8: no test data 2.4.8-p1: no test data 2.4.8-p2: no test data 2.4.8-p3: no test data 2.4.8-p4: no test data 2.4.8-p5: no test data
2.4.9
2.4.9 conflictcontains the fix
2.4.9: no test data

Triage

Model @cf/cloudflare/clef. Probability this is a bug fix: 97.9%. Probability it is security relevant: 2.1%.

Show the model's answers and probabilities
QuestionAnswerProbabilitiesConfidence
Change kindbugfixbugfix 96.4%, refactor 1.4%, tests_only 0.7%, feature 0.6%, dependency 0.5%, docs_only 0.4%91.6%
Areagraphql_apigraphql_api 92.3%, customer 2.7%, checkout 2.1%83.2%
Reported version2.4.82.4.8 54.4%, 2.4.8-p2 3.7%, 2.4.8-p1 3.4%29.3%
Scope0.29 of 20 75.4%, 1 19.8%, 2 4.8%41.4%
Risk0.29 of 20 79.8%, 1 11.1%, 2 9.2%48.6%
Worth backporting1.72 of 22 76.1%, 1 19.5%, 0 4.4%42.9%

Download

For cweagans/composer-patches, choose a version below and download the bundle. Copy its magento2-39972/ folder into patches/composer/, merge composer.patches.json into composer.json, then run composer install. Test files are always removed; paths are relative to each package root, using the default -p1 level.

Packages (1): magento/module-sales-graph-ql
Bundle README (what the ZIP ships)
# magento2-39972

Community fix merged upstream into magento/magento2, adapted by magento.watch.
This is not a patch published by Adobe.

Pull request: https://github.com/magento/magento2/pull/39972
Issue: https://github.com/magento/magento2/issues/39962
Author: @rogerdz
Source commit: a6c94c2683dbf293443b744cfc070662ac42bfba
Modifications: test files and documentation removed, paths rewritten relative to each Composer package.
Licence: OSL-3.0 / AFL-3.0, as the original Magento Open Source code.
Maintainer: Łukasz Bajsarowicz (@lbajsarowicz)

Licence: Magento Open Source code under OSL-3.0 and AFL-3.0. The bundle carries the original author, source commit and the list of modifications.

Sources

Łukasz Bajsarowicz
Built by

Łukasz Bajsarowicz, e-commerce architect

Magento and Adobe Commerce architecture, upgrades, performance and audits for merchants and agencies since 2015; magento.watch is the tooling I use on those projects.

Open source, maintained on weekends.