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

GraphQL OPTIONS request fails with error 500. #38738

Open william-gooch opened 5 months ago

william-gooch commented 5 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 5 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 5 months ago

@magento give me 2.4-develop instance

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

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

m2-assistant[bot] commented 5 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 5 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 5 months ago

Confirmed to occur on 2.4-develop instance

engcom-Delta commented 5 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 5 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 5 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 4 months ago

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

michelemiscusi commented 3 months 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

lano-vargas commented 3 months ago

Any updates/patch next release on the issue?

I get the following error in the exception.log

`Next Exception: Report ID: graph-ql-66acbdf8dc7a9; Message: Syntax Error: Unexpected in /var/www/vhosts/test.com/htdocs/vendor/magento/framework/GraphQl/Exception/ExceptionFormatter.php:64 Stack trace:

0 /var/www/vhosts/test.com/htdocs/generated/code/Magento/Framework/GraphQl/Exception/ExceptionFormatter/Interceptor.php(23): Magento\Framework\GraphQl\Exception\ExceptionFormatter->create()

1 /var/www/vhosts/test.com/htdocs/vendor/magento/module-graph-ql/Controller/GraphQl.php(210): Magento\Framework\GraphQl\Exception\ExceptionFormatter\Interceptor->create()

2 /var/www/vhosts/test.com/htdocs/vendor/magento/framework/Interception/Interceptor.php(58): Magento\GraphQl\Controller\GraphQl->dispatch()

3 /var/www/vhosts/test.com/htdocs/vendor/magento/framework/Interception/Interceptor.php(138): Magento\GraphQl\Controller\GraphQl\Interceptor->___callParent()

4 /var/www/vhosts/test.com/htdocs/vendor/fastly/magento2/Model/FrontControllerPlugin.php(135): Magento\GraphQl\Controller\GraphQl\Interceptor->Magento\Framework\Interception{closure}()

5 /var/www/vhosts/test.com/htdocs/vendor/magento/framework/Interception/Interceptor.php(135): Fastly\Cdn\Model\FrontControllerPlugin->aroundDispatch()

6 /var/www/vhosts/test.com/htdocs/vendor/magento/module-page-cache/Model/App/FrontController/BuiltinPlugin.php(72): Magento\GraphQl\Controller\GraphQl\Interceptor->Magento\Framework\Interception{closure}()

7 /var/www/vhosts/test.com/htdocs/vendor/magento/framework/Interception/Interceptor.php(135): Magento\PageCache\Model\App\FrontController\BuiltinPlugin->aroundDispatch()

8 /var/www/vhosts/test.com/htdocs/vendor/magento/framework/Interception/Interceptor.php(153): Magento\GraphQl\Controller\GraphQl\Interceptor->Magento\Framework\Interception{closure}()

9 /var/www/vhosts/test.com/htdocs/generated/code/Magento/GraphQl/Controller/GraphQl/Interceptor.php(23): Magento\GraphQl\Controller\GraphQl\Interceptor->___callPlugins()

10 /var/www/vhosts/test.com/htdocs/vendor/magento/framework/App/Http.php(116): Magento\GraphQl\Controller\GraphQl\Interceptor->dispatch()

11 /var/www/vhosts/test.com/htdocs/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\App\Http->launch()

12 /var/www/vhosts/test.com/htdocs/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\App\Http\Interceptor->___callParent()

13 /var/www/vhosts/test.com/htdocs/vendor/magento/module-application-performance-monitor/Plugin/ApplicationPerformanceMonitor.php(38): Magento\Framework\App\Http\Interceptor->Magento\Framework\Interception{closure}()

14 /var/www/vhosts/test.com/htdocs/vendor/magento/framework/Interception/Interceptor.php(135): Magento\ApplicationPerformanceMonitor\Plugin\ApplicationPerformanceMonitor->aroundLaunch()

15 /var/www/vhosts/test.com/htdocs/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\App\Http\Interceptor->Magento\Framework\Interception{closure}()

16 /var/www/vhosts/test.com/htdocs/generated/code/Magento/Framework/App/Http/Interceptor.php(23): Magento\Framework\App\Http\Interceptor->___callPlugins()

17 /var/www/vhosts/test.com/htdocs/vendor/magento/framework/App/Bootstrap.php(264): Magento\Framework\App\Http\Interceptor->launch()

18 /var/www/vhosts/test.com/htdocs/pub/index.php(30): Magento\Framework\App\Bootstrap->run()

19 {main} {"exception":"[object] (Exception(code: 0): Report ID: graph-ql-66acbdf8dc7a9; Message: Syntax Error: Unexpected at /var/www/vhosts/test.com/htdocs/vendor/magento/framework/GraphQl/Exception/ExceptionFormatter.php:64)

[previous exception] [object] (GraphQL\Error\SyntaxError(code: 0): Syntax Error: Unexpected at /var/www/vhosts/test.com/htdocs/vendor/webonyx/graphql-php/src/Language/Parser.php:433)"} []`