Magento2: X-Magento-Tags Header too long - Apache / PHP error 500 on category pages

Created on 21 Feb 2020  路  8Comments  路  Source: magento/magento2

Preconditions (*)

  1. Latest Magento 2.3.4 (Developer Mode)
  2. A category containing many (simple) products (in this case about 2600)
  3. No Varnish
  4. Apache + PHP7.3-FPM (happens with 7.2 too)

Steps to reproduce (*)

It seems magento creates http headers that are too long for most or some apache configurations. For me it happens when visiting a category page with many products.

PHP error log:

[Fri Feb 21 09:20:55.678915 2020] [proxy_fcgi:error] [pid 13470:tid 140320488904448] [client XXXXX:53641] Premature end of script headers: index.php, referer: https://XXXXX/shop/catalog/category/view/id/3
[Fri Feb 21 09:20:55.678978 2020] [proxy_fcgi:error] [pid 13470:tid 140320488904448] [client XXXXX:53641] AH01070: Error parsing script headers, referer: https://XXXXX/shop/catalog/category/view/id/3
[Fri Feb 21 09:20:55.678984 2020] [proxy_fcgi:error] [pid 13470:tid 140320488904448] (22)Invalid argument: [client XXXXX:53641] AH01075: Error dispatching request to : , referer: https://XXXXX...

Expected result (*)

I can understand that these headers are important for caching, and the HTTP spec doesnt define a limit for header sizes.
But most servers do in fact implement a limit (around ~8k), so i think this is a bug that should be fixed. https://stackoverflow.com/questions/686217/maximum-on-http-header-values

Actual result (*)

In my specific case, the http response is cached by magento FPC, and returned to the client in:
magento/vendor/magento/framework/App/Http.php:122

The X-Magento-Tags heade size is 27kB. The content is made up of strings like this one: cat_p_2611,cat_p,cat_p_2584,cat_p_2585.

If i add the following in the row after, the page works again:
$this->_response->setHeader('X-Magento-Tags', "test");

ready for confirmation Reported on 2.3.4

Most helpful comment

This is strongly related to https://github.com/magento/magento2/issues/6401 and is probably a duplicate.
But I'll leave this ticket open for now, since it needs to be more in the spotlight and needs to get fixed sooner rather than later.

All 8 comments

Hi @marvinhinz. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

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

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, please, review the Magento Contributor Assistant documentation.

@marvinhinz do you confirm that you were able to reproduce the issue on vanilla Magento instance following steps to reproduce?

  • [ ] yes
  • [ ] no

This is strongly related to https://github.com/magento/magento2/issues/6401 and is probably a duplicate.
But I'll leave this ticket open for now, since it needs to be more in the spotlight and needs to get fixed sooner rather than later.

I also faced the same issue and its due to long headers...

I can confirm, this can still be an issue with Magento 2.4.0

Hi @ihor-sviziev. 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.

Hi @marvinhinz,
Seems like issue was already fixed in #6401 and was already fixed in Magento 2.4.1.
Could you confirm that?

I can reproduce this in 2.3.5-p1

In order to have fully functional fix for all cases - we should introduce some tags splitting mechanism. There was one trial to do that in https://github.com/magento/magento2/pull/12831, but it wasn't finalized.
If someone interested in fixing this issue - please create PR with the same changes + fix the all requested changes in https://github.com/magento/magento2/pull/12831#pullrequestreview-128271255

Was this page helpful?
0 / 5 - 0 ratings