Open gwharton opened 3 months ago
Hi @gwharton. 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:
@magento give me 2.4-develop instance
- upcoming 2.4.x release@magento I am working on this
Join Magento Community Engineering Slack and ask your questions in #github channel. :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.
@magento give me 2.4-develop instance
Hi @gwharton. Thank you for your request. I'm working on Magento instance for you.
Hi @gwharton, here is your Magento Instance: https://3f0c00b51f03fb401baba059c392ecad.instances-prod.magento-community.engineering Admin access: https://3f0c00b51f03fb401baba059c392ecad.instances-prod.magento-community.engineering/admin_cfb3 Login: 00c0312d Password: 692da97476b5
ubuntu@megumi:~$ curl -I -u 00c0312d:692da97476b5 --header "Accept: text/html" https://3f0c00b51f03fb401baba059c392ecad.instances-prod.magento-community.engineering/checkout
HTTP/2 500
date: Mon, 08 Jul 2024 08:31:06 GMT
content-type: text/html; charset=UTF-8
server: Apache/2.4.59 (Ubuntu)
x-powered-by: PHP/8.2.20
pragma: no-cache
cache-control: max-age=0, must-revalidate, no-cache, no-store
expires: Sat, 08 Jul 2023 08:31:06 GMT
x-content-type-options: nosniff
x-xss-protection: 1; mode=block
x-frame-options: SAMEORIGIN
set-cookie: PHPSESSID=b009b5996669de3adf04861cab85049a; expires=Mon, 08 Jul 2024 09:31:06 GMT; Max-Age=3600; path=/; domain=3f0c00b51f03fb401baba059c392ecad.instances-prod.magento-community.engineering; HttpOnly; SameSite=Lax
Hi @engcom-Bravo. 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:
Area: XXXXX
label to the ticket, indicating the functional areas it may be related to.2.4-develop
branch@magento give me 2.4-develop instance
to deploy test instance on Magento infrastructure. 2.4-develop
branch, please, add the label Reproduced on 2.4.x
.Issue: Confirmed
once verification is complete. Hi @gwharton,
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 screenshot.
[2024-07-10T05:59:17.129413+00:00] main.CRITICAL: Magento\Framework\Webapi\Exception: Server cannot match any of the given Accept HTTP header media type(s) from the request: "text/html" with media types from the config of response renderer. in /usr/local/var/www/magentok/magento2/lib/internal/Magento/Framework/Webapi/Rest/Response/RendererFactory.php:84
Stack trace:
#0 /usr/local/var/www/magentok/magento2/lib/internal/Magento/Framework/Webapi/Rest/Response/RendererFactory.php(54): Magento\Framework\Webapi\Rest\Response\RendererFactory->_getRendererClass()
#1 /usr/local/var/www/magentok/magento2/lib/internal/Magento/Framework/Webapi/Rest/Response.php(45): Magento\Framework\Webapi\Rest\Response\RendererFactory->get()
#2 /usr/local/var/www/magentok/magento2/lib/internal/Magento/Framework/ObjectManager/Factory/AbstractFactory.php(121): Magento\Framework\Webapi\Rest\Response->__construct(Object(Magento\Framework\Webapi\Rest\Response\RendererFactory), Object(Magento\Framework\Webapi\ErrorProcessor), Object(Magento\Framework\App\State\Interceptor))
#3 /usr/local/var/www/magentok/magento2/lib/internal/Magento/Framework/ObjectManager/Factory/Dynamic/Developer.php(66): Magento\Framework\ObjectManager\Factory\AbstractFactory->createObject('Magento\\Framewo...', Array)
#4 /usr/local/var/www/magentok/magento2/lib/internal/Magento/Framework/ObjectManager/ObjectManager.php(73): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create('Magento\\Framewo...')
#5 /usr/local/var/www/magentok/magento2/app/code/Magento/Quote/Model/QuoteValidator.php(72): Magento\Framework\ObjectManager\ObjectManager->get('Magento\\Framewo...')
#6 /usr/local/var/www/magentok/magento2/lib/internal/Magento/Framework/ObjectManager/Factory/AbstractFactory.php(121): Magento\Quote\Model\QuoteValidator->__construct(NULL, NULL, NULL, NULL)
#7 /usr/local/var/www/magentok/magento2/lib/internal/Magento/Framework/ObjectManager/Factory/Dynamic/Developer.php(66): Magento\Framework\ObjectManager\Factory\AbstractFactory->createObject('Magento\\Quote\\M...', Array)
#8 /usr/local/var/www/magentok/magento2/lib/internal/Magento/Framework/ObjectManager/ObjectManager.php(73): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create('Magento\\Quote\\M...')
#9 /usr/local/var/www/magentok/magento2/lib/internal/Magento/Framework/ObjectManager/Factory/AbstractFactory.php(170): Magento\Framework\ObjectManager\ObjectManager->get('Magento\\Quote\\M...')
#10 /usr/local/var/www/magentok/magento2/lib/internal/Magento/Framework/ObjectManager/Factory/AbstractFactory.php(276): Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgument(Array, 'Magento\\Quote\\M...', NULL, 'quoteValidator', 'Magento\\Quote\\M...')
#11 /usr/local/var/www/magentok/magento2/lib/internal/Magento/Framework/ObjectManager/Factory/AbstractFactory.php(239): Magento\Framework\ObjectManager\Factory\AbstractFactory->getResolvedArgument('Magento\\Quote\\M...', Array, Array)
#12 /usr/local/var/www/magentok/magento2/lib/internal/Magento/Framework/ObjectManager/Factory/Dynamic/Developer.php(34): Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgumentsInRuntime('Magento\\Quote\\M...', Array, Array)
#13 /usr/local/var/www/magentok/magento2/lib/internal/Magento/Framework/ObjectManager/Factory/Dynamic/Developer.php(59): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->_resolveArguments('Magento\\Quote\\M...', Array, Array)
#14 /usr/local/var/www/magentok/magento2/lib/internal/Magento/Framework/ObjectManager/ObjectManager.php(59): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create('Magento\\Quote\\M...', Array)
#15 /usr/local/var/www/magentok/magento2/generated/code/Magento/Quote/Model/QuoteFactory.php(43): Magento\Framework\ObjectManager\ObjectManager->create('\\Magento\\Quote\\...', Array)
#16 /usr/local/var/www/magentok/magento2/app/code/Magento/Checkout/Model/Session.php(257): Magento\Quote\Model\QuoteFactory->create()
#17 /usr/local/var/www/magentok/magento2/generated/code/Magento/Checkout/Model/Session/Interceptor.php(50): Magento\Checkout\Model\Session->getQuote()
#18 /usr/local/var/www/magentok/magento2/app/code/Magento/Checkout/Controller/Onepage.php(153): Magento\Checkout\Model\Session\Interceptor->getQuote()
#19 /usr/local/var/www/magentok/magento2/lib/internal/Magento/Framework/Interception/Interceptor.php(58): Magento\Checkout\Controller\Onepage->dispatch(Object(Magento\Framework\App\Request\Http))
#20 /usr/local/var/www/magentok/magento2/lib/internal/Magento/Framework/Interception/Interceptor.php(138): Magento\Checkout\Controller\Index\Index\Interceptor->___callParent('dispatch', Array)
#21 /usr/local/var/www/magentok/magento2/lib/internal/Magento/Framework/Interception/Interceptor.php(153): Magento\Checkout\Controller\Index\Index\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#22 /usr/local/var/www/magentok/magento2/generated/code/Magento/Checkout/Controller/Index/Index/Interceptor.php(32): Magento\Checkout\Controller\Index\Index\Interceptor->___callPlugins('dispatch', Array, Array)
#23 /usr/local/var/www/magentok/magento2/lib/internal/Magento/Framework/App/FrontController.php(245): Magento\Checkout\Controller\Index\Index\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#24 /usr/local/var/www/magentok/magento2/lib/internal/Magento/Framework/App/FrontController.php(212): Magento\Framework\App\FrontController->getActionResponse(Object(Magento\Checkout\Controller\Index\Index\Interceptor), Object(Magento\Framework\App\Request\Http))
#25 /usr/local/var/www/magentok/magento2/lib/internal/Magento/Framework/App/FrontController.php(146): Magento\Framework\App\FrontController->processRequest(Object(Magento\Framework\App\Request\Http), Object(Magento\Checkout\Controller\Index\Index\Interceptor))
#26 /usr/local/var/www/magentok/magento2/lib/internal/Magento/Framework/Interception/Interceptor.php(58): Magento\Framework\App\FrontController->dispatch(Object(Magento\Framework\App\Request\Http))
#27 /usr/local/var/www/magentok/magento2/lib/internal/Magento/Framework/Interception/Interceptor.php(138): Magento\Framework\App\FrontController\Interceptor->___callParent('dispatch', Array)
#28 /usr/local/var/www/magentok/magento2/app/code/Magento/Store/App/FrontController/Plugin/RequestPreprocessor.php(99): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#29 /usr/local/var/www/magentok/magento2/lib/internal/Magento/Framework/Interception/Interceptor.php(135): Magento\Store\App\FrontController\Plugin\RequestPreprocessor->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#30 /usr/local/var/www/magentok/magento2/app/code/Magento/PageCache/Model/App/FrontController/BuiltinPlugin.php(76): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#31 /usr/local/var/www/magentok/magento2/lib/internal/Magento/Framework/Interception/Interceptor.php(135): Magento\PageCache\Model\App\FrontController\BuiltinPlugin->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#32 /usr/local/var/www/magentok/magento2/lib/internal/Magento/Framework/Interception/Interceptor.php(153): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#33 /usr/local/var/www/magentok/magento2/generated/code/Magento/Framework/App/FrontController/Interceptor.php(23): Magento\Framework\App\FrontController\Interceptor->___callPlugins('dispatch', Array, NULL)
#34 /usr/local/var/www/magentok/magento2/lib/internal/Magento/Framework/App/Http.php(116): Magento\Framework\App\FrontController\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#35 /usr/local/var/www/magentok/magento2/lib/internal/Magento/Framework/Interception/Interceptor.php(58): Magento\Framework\App\Http->launch()
#36 /usr/local/var/www/magentok/magento2/lib/internal/Magento/Framework/Interception/Interceptor.php(138): Magento\Framework\App\Http\Interceptor->___callParent('launch', Array)
#37 /usr/local/var/www/magentok/magento2/app/code/Magento/ApplicationPerformanceMonitor/Plugin/ApplicationPerformanceMonitor.php(38): Magento\Framework\App\Http\Interceptor->Magento\Framework\Interception\{closure}()
#38 /usr/local/var/www/magentok/magento2/lib/internal/Magento/Framework/Interception/Interceptor.php(135): Magento\ApplicationPerformanceMonitor\Plugin\ApplicationPerformanceMonitor->aroundLaunch(Object(Magento\Framework\App\Http\Interceptor), Object(Closure))
#39 /usr/local/var/www/magentok/magento2/lib/internal/Magento/Framework/Interception/Interceptor.php(153): Magento\Framework\App\Http\Interceptor->Magento\Framework\Interception\{closure}()
#40 /usr/local/var/www/magentok/magento2/generated/code/Magento/Framework/App/Http/Interceptor.php(23): Magento\Framework\App\Http\Interceptor->___callPlugins('launch', Array, NULL)
#41 /usr/local/var/www/magentok/magento2/lib/internal/Magento/Framework/App/Bootstrap.php(264): Magento\Framework\App\Http\Interceptor->launch()
#42 /usr/local/var/www/magentok/magento2/pub/index.php(30): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http\Interceptor))
#43 {main} {"report_id":"f571ac7b359a5fe2fc3b5bf6bbe248c817bfa08d56f186f33e2dc745ddc3daa3","exception":"[object] (Magento\\Framework\\Webapi\\Exception(code: 0): Server cannot match any of the given Accept HTTP header media type(s) from the request: \"text/html\" with media types from the config of response renderer. at /usr/local/var/www/magentok/magento2/lib/internal/Magento/Framework/Webapi/Rest/Response/RendererFactory.php:84)"} []
Hence Confirming the issue.
Thanks.
:white_check_mark: Jira issue https://jira.corp.adobe.com/browse/AC-12386 is successfully created for this GitHub issue.
:white_check_mark: Confirmed by @engcom-Bravo. Thank you for verifying the issue.
Issue Available: @engcom-Bravo, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.
This issue is spamming our logs :)
Yep, yandex crawlers all run with accept text/html. That's how I noticed it in my logs.
Issue is caused by this line.
It seems REST specific response object with instance \Magento\Framework\Webapi\Rest\Response
was injected into general model such as \Magento\Quote\Model\QuoteValidator
. For me issue happens when object manager tries to create \Magento\NegotiableQuote\Model\Plugin\Checkout\Model\SessionPlugin
on the very early stage of execution any page, but not only REST API related calls.
Yeah, if you have the Stripe payment module installed, it also occurs on every page for a similar reason. They add a plugin to the main Front controller which causes it to trigger for every page.
Is there any update on this issue?
Here's a patch for logs spam, at least until the issue is fixed in the repo:
diff --git a/vendor/magento/module-quote/Model/QuoteValidator.php b/vendor/magento/module-quote/Model/QuoteValidator.php
--- a/vendor/magento/module-quote/Model/QuoteValidator.php (revision 6aee74ca7b27e3d7904f5160017bab9568f9d60d)
+++ b/vendor/magento/module-quote/Model/QuoteValidator.php (date 1723630766091)
@@ -14,7 +14,6 @@
use Magento\Quote\Model\Quote as QuoteEntity;
use Magento\Quote\Model\Quote\Validator\MinimumOrderAmount\ValidationMessage as OrderAmountValidationMessage;
use Magento\Quote\Model\ValidationRules\QuoteValidationRuleInterface;
-use Magento\Framework\Webapi\Rest\Response as RestResponse;
/**
* Class to validate the quote
@@ -44,24 +43,17 @@
*/
private $quoteValidationRule;
- /**
- * @var RestResponse
- */
- private $_response;
-
/**
* QuoteValidator constructor.
*
* @param AllowedCountries|null $allowedCountryReader
* @param OrderAmountValidationMessage|null $minimumAmountMessage
* @param QuoteValidationRuleInterface|null $quoteValidationRule
- * @param RestResponse|null $response
*/
public function __construct(
AllowedCountries $allowedCountryReader = null,
OrderAmountValidationMessage $minimumAmountMessage = null,
- QuoteValidationRuleInterface $quoteValidationRule = null,
- RestResponse $response = null
+ QuoteValidationRuleInterface $quoteValidationRule = null
) {
$this->allowedCountryReader = $allowedCountryReader ?: ObjectManager::getInstance()
->get(AllowedCountries::class);
@@ -69,7 +61,6 @@
->get(OrderAmountValidationMessage::class);
$this->quoteValidationRule = $quoteValidationRule ?: ObjectManager::getInstance()
->get(QuoteValidationRuleInterface::class);
- $this->_response = $response ?: ObjectManager::getInstance()->get(RestResponse::class);
}
/**
@@ -115,7 +106,6 @@
$defaultMessage .= ' %1';
}
if ($defaultMessage) {
- $this->_response->setHeader('errorRedirectAction', '#shipping');
throw new ValidatorException(__($defaultMessage, implode(' ', $messages)));
}
}
Is this fixed in Magento v2.4.7-p2?
@PaulWatt No, we are seeing this in v2.4.7-p2.
Preconditions and environment
Magento v2.4.7-p1
Steps to reproduce
Deploy Vanilla Magento 2.4.7-p1 curl -I --header "Accept: text/html" https://testdomain.com/checkout
Expected result
HTTP/2 200
Actual result
HTTP/2 500
Additional information
Any page that has an ultimate DI dependency on the class
Magento\Framework\Webapi\Rest\Response
will return a 500 if the Accept header is not one of{*}/{*}
,application/json
orapplication/xml
.This is because the constructor of the
Magento\Framework\Webapi\Rest\Response
class loads all WebApi renderers and checks the Accept header of the current call, regardless of whether the actual web request was a Webapi request or not.The DI dependency tree on
Magento\Framework\Webapi\Rest\Response
includes the classMagento\Quote\Model\QuoteValidator
which ofcourse means that any calls to the checkout on a vanilla install with the headerAccept: text/html
will fail.I suspect there are other dependency paths that result in the instantiation of a
"Magento\Framework\Webapi\Rest\Response"\
object in the constructor that are used for regular Web requests, and these too will fail if the"Accept: text/html"
header is set.Release note
Magento now correctly handles regular web requests when the HTTP Accept header is set to "text/html". Previously, an exception was generated if the webpage had a dependency link to the "Magento\Framework\Webapi\Rest\Response" class.
Triage and priority