magento2 icon indicating copy to clipboard operation
magento2 copied to clipboard

Internal Server Error in PUT /pub/rest/default/V1/bundle-products/options/

Open mlf20 opened this issue 2 years ago • 7 comments

Preconditions and environment

  • Magento version: 2.4

Steps to reproduce

  1. Retrieve auth token from the admin endpoint /V1/integration/admin/token
  2. Request endpoint:
curl -H 'Content-Type: application/json' -H 'Authorization: Bearer' <AUTH TOKEN> -d '{}' -X PUT http://<MAGENTO_URL>/pub/rest/default/V1/bundle-products/options/DZ.pdf?option=

Expected result

Returns a 400 error as the request is malformed.

Actual result

Returns a 500 status code as an error is thrown as getProductFromLocalCache() takes a null argument which is not handled.

Additional information

output of var/log/system.log:

[2022-08-01T10:37:43.276366+00:00] main.CRITICAL: TypeError: Magento\Catalog\Model\ProductRepository::getProductFromLocalCache(): Argument #1 ($sku) must be of type string, null given, called in /bitnami/magento/vendor/magento/module-catalog/Model/ProductRepository.php on line 284 and defined in /bitnami/magento/vendor/magento/module-catalog/Model/ProductRepository.php:813
Stack trace:
#0 /bitnami/magento/vendor/magento/module-catalog/Model/ProductRepository.php(284): Magento\Catalog\Model\ProductRepository->getProductFromLocalCache()
#1 /bitnami/magento/generated/code/Magento/Catalog/Model/ProductRepository/Interceptor.php(23): Magento\Catalog\Model\ProductRepository->get()
#2 /bitnami/magento/vendor/magento/module-bundle/Model/OptionManagement.php(41): Magento\Catalog\Model\ProductRepository\Interceptor->get()
#3 [internal function]: Magento\Bundle\Model\OptionManagement->save()
#4 /bitnami/magento/vendor/magento/module-webapi/Controller/Rest/SynchronousRequestProcessor.php(95): call_user_func_array()
#5 /bitnami/magento/vendor/magento/module-webapi/Controller/Rest.php(188): Magento\Webapi\Controller\Rest\SynchronousRequestProcessor->process()
#6 /bitnami/magento/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Webapi\Controller\Rest->dispatch()
#7 /bitnami/magento/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Webapi\Controller\Rest\Interceptor->___callParent()
#8 /bitnami/magento/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Webapi\Controller\Rest\Interceptor->Magento\Framework\Interception\{closure}()
#9 /bitnami/magento/generated/code/Magento/Webapi/Controller/Rest/Interceptor.php(23): Magento\Webapi\Controller\Rest\Interceptor->___callPlugins()
#10 /bitnami/magento/vendor/magento/framework/App/Http.php(116): Magento\Webapi\Controller\Rest\Interceptor->dispatch()
#11 /bitnami/magento/generated/code/Magento/Framework/App/Http/Interceptor.php(23): Magento\Framework\App\Http->launch()
#12 /bitnami/magento/vendor/magento/framework/App/Bootstrap.php(264): Magento\Framework\App\Http\Interceptor->launch()
#13 /bitnami/magento/pub/index.php(30): Magento\Framework\App\Bootstrap->run()
#14 {main} [] []

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.
  • [X] 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”.

mlf20 avatar Aug 12 '22 09:08 mlf20

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

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

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.


:warning: According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

: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] avatar Aug 12 '22 09:08 m2-assistant[bot]

@magento give me 2.4-develop instance

mlf20 avatar Aug 12 '22 09:08 mlf20

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

Hi @mlf20, here is your Magento Instance: https://02cad0f8b82405bcc036dbe136a33ab0.instances.magento-community.engineering Admin access: https://02cad0f8b82405bcc036dbe136a33ab0.instances.magento-community.engineering/admin_bcc5 Login: 8a862b9d Password: b5ecd2a33db6

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

  • [ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • [ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • [ ] 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • [ ] 4. Verify that the issue is reproducible on 2.4-develop branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - 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.

m2-assistant[bot] avatar Aug 12 '22 09:08 m2-assistant[bot]

Hi @mlf20 , Thank you for raising an issue , We tried to reproduce with provided steps, in fact we are not able to reproduce the error after running endpoint on Magento 2.4 develop. Here is the screenshot for reference.

Screenshot 2022-08-12 at 5 32 19 PM

Please review and confirm the steps.

Note : Kindly request to review issue description and steps.

engcom-Delta avatar Aug 12 '22 12:08 engcom-Delta

Hi @engcom-Delta,

Thanks for looking into this, please note that the endpoint with the error is /pub/rest/default/V1/bundle-products/options/{optionId}. The request should be formed as: curl -H 'Content-Type: application/json' -H 'Authorization: Bearer' <AUTH TOKEN> -d '{}' -X PUT http://<MAGENTO_URL>/pub/rest/default/V1/bundle-products/options/DZ.pdf?option=

To reproduce this:

  1. Retrieve the admin token from the relevant endpoint
  2. Then use that token to access the /pub/rest/default/V1/bundle-products/options/{optionId} endpoint.

I was able to confirm this on the 2.4 develop instance provided by Magento Deployment Service.

I hope this makes sense.

mlf20 avatar Aug 12 '22 12:08 mlf20

Hi @mlf20 , Thank you for providing the inputs , we tried to replicate on magento 2.4 instance but we are not facing the same error. it would be great help what was your request body that you were trying.

in my local i have tried below endpoint and request body.

Endpoint[PUT]: http://local.magento.com/rest/default/V1/bundle-products/options/0

Body : { "option": { "option_id": 0, "title": "option1", "required": true, "type": "Multiple Select", "position": 0, "sku": "Bundle1", "product_links": [ { "id": "0", "sku": "MB-2401", "option_id": 0, "qty": 1, "position": 0, "is_default": true, "price": 34, "price_type": null, "can_change_quantity": 0, "extension_attributes": {} } ], "extension_attributes": {} } }

Response: Screenshot 2022-08-23 at 7 15 58 PM

This is the data issue i believe.

engcom-Delta avatar Aug 23 '22 13:08 engcom-Delta

Hi @engcom-Delta,

I have gone over my logs and the payload in the body should be '{}'

This reproduces the issue on a 2.4 develop instance as shown below:

Screenshot 2022-08-23 at 15 01 24

mlf20 avatar Aug 23 '22 14:08 mlf20

Hi @mlf20 , Thank for your quick turnaround. We tried again magento 2.4 delovelop instance, it works fine . Please find below screenshot and video for reference.

Screenshot 2022-08-25 at 5 51 36 PM

https://www.loom.com/share/30b8d9ac9ce34cdab74d9b9b27efebb7

engcom-Delta avatar Aug 25 '22 13:08 engcom-Delta

Hi @engcom-Delta,

It appears that you have used a request body that includes all the correct parameters. However, the error is triggered when setting the entire body to be empty json, as I have shown in the above request body this should be simply: {}. This will reproduce the error.

Many thanks

mlf20 avatar Aug 26 '22 10:08 mlf20

Hi @mlf20 , Thank you for the update , We have tried with empty json :{} in entire body and triggered ,we got "field name is required. Enter and try again" error. please review the screenshot.

Screenshot 2022-08-29 at 3 32 52 PM

engcom-Delta avatar Aug 29 '22 10:08 engcom-Delta

Hi @mlf20 ,

We have noticed that, this issue has not been updated for a period of 14 Days.Hence we assume that this issue is fixed now, so we are closing it. Please raise a fresh ticket or reopen this ticket if you need more assistance on this.

Thanks.

engcom-Delta avatar Sep 12 '22 12:09 engcom-Delta