magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.57k stars 9.32k forks source link

Internal Server Error in /V1/creditmemo API Endpoint #35924

Open mlf20 opened 2 years ago

mlf20 commented 2 years ago

Preconditions and environment

Steps to reproduce

  1. Retrieve auth token from the admin endpoint /V1/integration/admin/
  2. Request endpoint:
curl -H 'Content-Type: application/json' -H 'Authorization: Bearer' <AUTH TOKEN> -d '{"entity": ""}' -X POST http://<MAGENTO_URL>/pub/rest/default/V1/creditmemo

Expected result

Returns a 400 error as the request is malformed.

Actual result

Returns a 500 status code.

Additional information

output of var/log/system.log:

[2022-08-01T11:34:36.255953+00:00] main.CRITICAL: Error: Call to a member function getId() on null in /magento/vendor/magento/module-sales/Model/ResourceModel/Order/Creditmemo.php:50
    Stack trace:
    #0 /magento/vendor/magento/framework/Model/ResourceModel/Db/AbstractDb.php(393): Magento\Sales\Model\ResourceModel\Order\Creditmemo->_beforeSave()
    #1 /magento/vendor/magento/module-sales/Model/Order/CreditmemoRepository.php(141): Magento\Framework\Model\ResourceModel\Db\AbstractDb->save()
    #2 /magento/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Sales\Model\Order\CreditmemoRepository->save()
    #3 /magento/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Sales\Model\Order\CreditmemoRepository\Interceptor->___callParent()
    #4 /magento/vendor/magento/module-inventory-sales/Plugin/Sales/OrderManagement/DeductSourceItemQuantityOnRefundPlugin.php(96): Magento\Sales\Model\Order\CreditmemoRepository\Interceptor->Magento\Framework\Interception\{closure}()
    #5 /magento/vendor/magento/framework/Interception/Interceptor.php(135): Magento\InventorySales\Plugin\Sales\OrderManagement\DeductSourceItemQuantityOnRefundPlugin->aroundSave()
    #6 /magento/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Sales\Model\Order\CreditmemoRepository\Interceptor->Magento\Framework\Interception\{closure}()
    #7 /magento/generated/code/Magento/Sales/Model/Order/CreditmemoRepository/Interceptor.php(59): Magento\Sales\Model\Order\CreditmemoRepository\Interceptor->___callPlugins()
    #8 [internal function]: Magento\Sales\Model\Order\CreditmemoRepository\Interceptor->save()
    #9 /magento/vendor/magento/module-webapi/Controller/Rest/SynchronousRequestProcessor.php(95): call_user_func_array()
    #10 /magento/vendor/magento/module-webapi/Controller/Rest.php(188): Magento\Webapi\Controller\Rest\SynchronousRequestProcessor->process()
    #11 /magento/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Webapi\Controller\Rest->dispatch()
    #12 /magento/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Webapi\Controller\Rest\Interceptor->___callParent()
    #13 /magento/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Webapi\Controller\Rest\Interceptor->Magento\Framework\Interception\{closure}()
    #14 /magento/generated/code/Magento/Webapi/Controller/Rest/Interceptor.php(23): Magento\Webapi\Controller\Rest\Interceptor->___callPlugins()
    #15 /magento/vendor/magento/framework/App/Http.php(116): Magento\Webapi\Controller\Rest\Interceptor->dispatch()
    #16 /magento/generated/code/Magento/Framework/App/Http/Interceptor.php(23): Magento\Framework\App\Http->launch()
    #17 /magento/vendor/magento/framework/App/Bootstrap.php(264): Magento\Framework\App\Http\Interceptor->launch()
    #18 /magento/pub/index.php(30): Magento\Framework\App\Bootstrap->run()
    #19 {main} [] []

Release note

No response

Triage and priority

m2-assistant[bot] commented 2 years ago

Hi @mlf20. Thank you for your report. To speed up processing of this issue, make sure that you provided the following information:

Make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, review the Magento Contributor Assistant documentation.

Add a comment to assign the issue: @magento I am working on this

To learn more about issue processing workflow, refer to the Code Contributions.


:clock10: You can find the schedule on the Magento Community Calendar page.

:telephone_receiver: 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.

:pencil2: Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

m2-assistant[bot] commented 2 years ago

Hi @engcom-November. 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: :point_down:

engcom-November commented 2 years ago

Verified the issue on Magento 2.4-develop branch and the issue is reproducible. Hence confirming this issue. image

Exception stack trace

[2022-08-16T11:33:36.482233+00:00] main.CRITICAL: Error: Call to a member function getId() on null in /var/www/html/mg24ce/magento2ce/app/code/Magento/Sales/Model/ResourceModel/Order/Creditmemo.php:50
Stack trace:
#0 /var/www/html/mg24ce/magento2ce/lib/internal/Magento/Framework/Model/ResourceModel/Db/AbstractDb.php(393): Magento\Sales\Model\ResourceModel\Order\Creditmemo->_beforeSave()
#1 /var/www/html/mg24ce/magento2ce/app/code/Magento/Sales/Model/Order/CreditmemoRepository.php(141): Magento\Framework\Model\ResourceModel\Db\AbstractDb->save()
#2 [internal function]: Magento\Sales\Model\Order\CreditmemoRepository->save()
#3 /var/www/html/mg24ce/magento2ce/app/code/Magento/Webapi/Controller/Rest/SynchronousRequestProcessor.php(95): call_user_func_array()
#4 /var/www/html/mg24ce/magento2ce/app/code/Magento/Webapi/Controller/Rest.php(195): Magento\Webapi\Controller\Rest\SynchronousRequestProcessor->process()
#5 /var/www/html/mg24ce/magento2ce/lib/internal/Magento/Framework/Interception/Interceptor.php(58): Magento\Webapi\Controller\Rest->dispatch()
#6 /var/www/html/mg24ce/magento2ce/lib/internal/Magento/Framework/Interception/Interceptor.php(138): Magento\Webapi\Controller\Rest\Interceptor->___callParent()
#7 /var/www/html/mg24ce/magento2ce/lib/internal/Magento/Framework/Interception/Interceptor.php(153): Magento\Webapi\Controller\Rest\Interceptor->Magento\Framework\Interception\{closure}()
#8 /var/www/html/mg24ce/magento2ce/generated/code/Magento/Webapi/Controller/Rest/Interceptor.php(23): Magento\Webapi\Controller\Rest\Interceptor->___callPlugins()
#9 /var/www/html/mg24ce/magento2ce/lib/internal/Magento/Framework/App/Http.php(116): Magento\Webapi\Controller\Rest\Interceptor->dispatch()
#10 /var/www/html/mg24ce/magento2ce/lib/internal/Magento/Framework/App/Bootstrap.php(264): Magento\Framework\App\Http->launch()
#11 /var/www/html/mg24ce/magento2ce/pub/index.php(30): Magento\Framework\App\Bootstrap->run()
#12 {main} [] []
github-jira-sync-bot commented 2 years ago

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

m2-assistant[bot] commented 2 years ago

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

engcom-Delta commented 1 month ago

Hi @mlf20 ,

Thanks for your reporting and collaboration. We have re-verified the issue in latest 2.4-develop instance and the issue is reproducible. Kindly refer the screenshots.

Steps to reproduce

  1. Retrieve auth token from the admin endpoint /V1/integration/admin/
  2. Request endpoint: rest/V1/creditmemo
  3. Returns a 500 status code. image

Thanks.