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.4k stars 9.29k forks source link

GraphQL OPTIONS request fails with error 500. #38738

Open william-gooch opened 2 months ago

william-gooch commented 2 months ago

Preconditions and environment

Steps to reproduce

  1. Attempt to make an OPTIONS request against the GraphQL endpoint curl -i -X OPTIONS http://test.site/graphql

Expected result

Returns the "unexpected EOF" error but with a 200 status code so that CORS requests succeed.

Actual result

Returns the "unexpected EOF" error with a 500 status code, so CORS preflight requests always fail.

Additional information

This seems like it re-introduces MDVA-35312 which was previously fixed in Magento 2.4.3. I believe this is caused by https://github.com/magento/magento2/blame/c6bc8300e771e5e96ce9ac6c116746fe3de80544/app/code/Magento/GraphQl/Controller/GraphQl.php#L194 which parses the query and returns an error even if the request validators succeed.

Release note

No response

Triage and priority

m2-assistant[bot] commented 2 months ago

Hi @william-gooch. 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. To deploy vanilla Magento instance on our environment, Add a comment to the issue:

william-gooch commented 2 months ago

@magento give me 2.4-develop instance

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

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

m2-assistant[bot] commented 2 months ago

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:

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

Hi @william-gooch, here is your Magento Instance: https://e4f1dc96fd2a29c0dfef62b22c58308a.instances-prod.magento-community.engineering Admin access: https://e4f1dc96fd2a29c0dfef62b22c58308a.instances-prod.magento-community.engineering/admin_3d27 Login: 98152775 Password: bb2af77d0df9

william-gooch commented 2 months ago

Confirmed to occur on 2.4-develop instance

engcom-Delta commented 2 months ago

Hi @william-gooch ,

Verified the issue on 2.4.7 and 2.4-develop, it is reproducible.

Hence, Confirming the issue.

Steps to reproduce:-

  1. Attempt to make an OPTIONS request against the GraphQL endpoint curl -i -X OPTIONS http://test.site/graphql

2.4.7

Screenshot 2024-05-22 at 4 00 27 PM

2.4-develop

Screenshot 2024-05-22 at 4 00 49 PM
github-jira-sync-bot commented 2 months ago

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

m2-assistant[bot] commented 2 months ago

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

Detzler commented 1 month ago

Just upgraded from 2.4.6-p6 to 2.4.7-p1. Bug appeared under 2.4.7.

michelemiscusi commented 2 days ago

When magento tries to recover the query it checks the request url or body based on HTTP METHOD in case of OPTIONS it returns an empty array that when parsed using graphql source triggers an error image

overriding statusCode with 200 in case of OPTIONS method it works image