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.55k stars 9.32k forks source link

Internal Server Error in /V1/products/special-price API Endpoint #35934

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. Send post request to below endpoints with the payload: Payload: {"prices": "[]"}

or {"prices": ""}

API's effected with above payload:

  1. POST request to http://yourstore/rest/default/V1/products/special-price
  2. /V1/products/base-prices
  3. /V1/products/cost
  4. /V1/products/special-price-delete
  5. /V1/products/tier-prices-delete
  6. /V1/products/tier-prices
  7. /V1/inventory/is-product-salable-for-requested-qty/{sku}/{stockId}/{requestedQty}

Expected result

Returns a 400 error as the request is malformed.

Actual result

Returns a 500 status code from a null TypeError .

Additional information

output of var/log/system.log:

    [2022-08-01T13:05:39.434987+00:00] main.CRITICAL: TypeError: Magento\Catalog\Model\Product\Price\SpecialPriceStorage::update(): Argument #1 ($prices) must be of type array, null given in /magento/vendor/magento/module-catalog/Model/Product/Price/SpecialPriceStorage.php:125
    Stack trace:
    #0 [internal function]: Magento\Catalog\Model\Product\Price\SpecialPriceStorage->update()
    #1 /magento/vendor/magento/module-webapi/Controller/Rest/SynchronousRequestProcessor.php(95): call_user_func_array()
    #2 /magento/vendor/magento/module-webapi/Controller/Rest.php(188): Magento\Webapi\Controller\Rest\SynchronousRequestProcessor->process()
    #3 /magento/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Webapi\Controller\Rest->dispatch()
    #4 /magento/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Webapi\Controller\Rest\Interceptor->___callParent()
    #5 /magento/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Webapi\Controller\Rest\Interceptor->Magento\Framework\Interception\{closure}()
    #6 /magento/generated/code/Magento/Webapi/Controller/Rest/Interceptor.php(23): Magento\Webapi\Controller\Rest\Interceptor->___callPlugins()
    #7 /magento/vendor/magento/framework/App/Http.php(116): Magento\Webapi\Controller\Rest\Interceptor->dispatch()
    #8 /magento/generated/code/Magento/Framework/App/Http/Interceptor.php(23): Magento\Framework\App\Http->launch()
    #9 /magento/vendor/magento/framework/App/Bootstrap.php(264): Magento\Framework\App\Http\Interceptor->launch()
    #10 /magento/pub/index.php(30): Magento\Framework\App\Bootstrap->run()
    #11 {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

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 2 years ago

Hi @engcom-November. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 2 years ago

Hi @engcom-November, here is your Magento Instance: https://334b8526e05c78ff6198b9cb88e71670.instances.magento-community.engineering Admin access: https://334b8526e05c78ff6198b9cb88e71670.instances.magento-community.engineering/admin_ca39 Login: 21eb774a Password: 412515e8a617

engcom-November commented 2 years ago

Hi @mlf20 , Verified the issue on Magento 2.4-develop branch but could not reproduce the issue. image image Kindly check Magento system requirements and 3rd party exntensions / modules enabled is causing this issue. Kindly recheck the issue on Magento 2.4-develop branch and provide missing steps if any if you are still facing any issues. Thank you

mlf20 commented 2 years ago

Hi @engcom-November,

Thanks for looking at this, I believe the reason you are unable to reproduce this is due to the use of the 'prices' in the reequest body.

In my original issue the body of the request malformed, being set to: '{"prices": "\"[]\""}'. I believe if you set the body of the request to the same as this you will be able to reproduce the error.

Many thanks

engcom-November commented 2 years ago

Hi @mlf20 Getting expected result: 400 bad request error on 2.4-develop branch image Kindly check Magento system requirements and 3rd party exntensions / modules enabled is causing this issue. Kindly recheck the issue on Magento 2.4-develop branch and provide missing steps if any if you are still facing any issues. Thank you

mlf20 commented 2 years ago

Hi @engcom-November,

My apologies, I have gone over my logs and the payload in thebody should be '{"prices": "[]"}' . Due to formatting the initial request body had escaped additional characters. I will update the remaining issues.

This reproduces the issue as shown below: Screenshot 2022-08-12 at 16 11 18

engcom-November commented 2 years ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 2 years ago

Hi @engcom-November. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 2 years ago

Hi @engcom-November, here is your Magento Instance: https://334b8526e05c78ff6198b9cb88e71670.instances.magento-community.engineering Admin access: https://334b8526e05c78ff6198b9cb88e71670.instances.magento-community.engineering/admin_925c Login: 1516aeb2 Password: 3e2fb8a8aea7

engcom-November commented 2 years ago

Thanks for the update @mlf20 . Verified the issue on Magento 2.4-develop branch and the issue is reproducible. Hence updating the description and confirming the issue. image

github-jira-sync-bot commented 2 years ago

:white_check_mark: Jira issue https://jira.corp.adobe.com/browse/AC-6419 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.

serbynskyi commented 1 year ago

@magento I am working on this

JettyRohanAditya commented 1 year ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 1 year ago

Hi @JettyRohanAditya. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 1 year ago

Hi @JettyRohanAditya, here is your Magento Instance: https://334b8526e05c78ff6198b9cb88e71670.instances-prod.magento-community.engineering Admin access: https://334b8526e05c78ff6198b9cb88e71670.instances-prod.magento-community.engineering/admin_b5c3 Login: c06425a8 Password: be57660c8cd8

engcom-Delta commented 1 month ago

Hi @mlf20 ,

Thanks for your reporting and collaboration. We have 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. Send post request to below endpoints with the payload: Payload: {"prices": "[]"}
  3. POST request to http://yourstore/rest/default/V1/products/special-price image

Thanks.

github-jira-sync-bot commented 1 month ago

:x: Cannot export the issue. This GitHub issue is already linked to Jira issue(s): https://jira.corp.adobe.com/browse/AC-6419