Skip to content

Error getting order item coupon code for customer order via GraphQl customer request #39962

Open
@zakdma

Description

@zakdma
Contributor

Preconditions and environment

Magento 2.4.8

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)"} []

Additional information

There is a related bug #39841 that has been fixed. It fixes a similar case, but not this one.

Release note

No response

Triage and priority

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
    Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
    Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
    Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
    Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

Activity

m2-assistant

m2-assistant commented on Jun 5, 2025

@m2-assistant

Hi @zakdma. Thank you for your report.
To speed up processing of this issue, make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce.


Join Magento Community Engineering Slack and ask your questions in #github channel.
⚠️ According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.
🕙 You can find the schedule on the Magento Community Calendar page.
📞 The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.

self-assigned this
on Jun 5, 2025
m2-assistant

m2-assistant commented on Jun 5, 2025

@m2-assistant

Hi @engcom-Bravo. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
    2. Verify that issue has a meaningful description and provides enough information to reproduce the issue.
    3. Add Area: XXXXX label to the ticket, indicating the functional areas it may be related to.
    4. Verify that the issue is reproducible on 2.4-develop branch
    Details- If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!
    5. Add label Issue: Confirmed once verification is complete.
    6. Make sure that automatic system confirms that report has been added to the backlog.
engcom-Bravo

engcom-Bravo commented on Jun 5, 2025

@engcom-Bravo
Contributor

Hi @zakdma,

Thanks for your reporting and collaboration.

Can we close one of the issue looks like both are similar can you please confirm.

Thanks.

moved this from Ready for Confirmation to Needs Update in Issue Confirmation and Triage Boardon Jun 5, 2025
zakdma

zakdma commented on Jun 5, 2025

@zakdma
ContributorAuthor

Hi @zakdma,

Thanks for your reporting and collaboration.

Can we close one of the issue looks like both are similar can you please confirm.

Thanks.

Hey, @engcom-Bravo
Please do not close any, they are different issues, but regarding the same functionality.

engcom-Bravo

engcom-Bravo commented on Jun 6, 2025

@engcom-Bravo
Contributor

Hi @zakdma,

Thanks for your Update.

We have tried to reproduce the issue in Latest 2.4-develop instance and we are able to reproduce the issue.Kindly refer the screenshots.

Image
[2025-06-06T08:30:45.865491+00:00] main.ERROR: "discount_model" value should be specified

GraphQL (12:13)
11:           discounts {
12:             coupon {
                ^
13:               code
 {"exception":"[object] (GraphQL\\Error\\Error(code: 0): \"discount_model\" value should be specified at /usr/local/var/www/magentok/magento2/vendor/webonyx/graphql-php/src/Error/Error.php:170)
[previous exception] [object] (Magento\\Framework\\Exception\\LocalizedException(code: 0): \"discount_model\" value should be specified at /usr/local/var/www/magentok/magento2/app/code/Magento/SalesRuleGraphQl/Model/Resolver/Coupon.php:40)"} []


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

Hence Confirming the issue.

Thanks.

added
Issue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmed
Reproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branch
Priority: P2A defect with this priority could have functionality issues which are not to expectations.
and removed
Issue: needs updateAdditional information is require, waiting for response
on Jun 6, 2025
github-jira-sync-bot

github-jira-sync-bot commented on Jun 6, 2025

@github-jira-sync-bot

✅ Jira issue https://jira.corp.adobe.com/browse/AC-14889 is successfully created for this GitHub issue.

m2-assistant

m2-assistant commented on Jun 6, 2025

@m2-assistant

✅ Confirmed by @engcom-Bravo. Thank you for verifying the issue.
Issue Available: @engcom-Bravo, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: PromotionComponent: GraphQLGraphQLIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P2A defect with this priority could have functionality issues which are not to expectations.Reported on 2.4.8Indicates original Magento version for the Issue report.Reproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branch

    Type

    No type

    Projects

    Status

    Ready for Development

    Milestone

    No milestone

    Relationships

    None yet

      Participants

      @zakdma@engcom-Bravo@github-jira-sync-bot

      Issue actions

        Error getting order item coupon code for customer order via GraphQl customer request · Issue #39962 · magento/magento2