Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Large 'include' argument can cause '502 Bad Gateway' server error #11541

Open
danielbachhuber opened this issue Nov 6, 2018 · 5 comments
Open
Labels
[Package] Data /packages/data REST API Interaction Related to REST API [Type] Bug An existing feature does not function as intended

Comments

@danielbachhuber
Copy link
Member

To test #11524, I assigned 201 tags to my post with:

wp term generate post_tag --count=200
wp term list post_tag --field=id | xargs -I % wp post term add 75 post_tag % --by=id

When I loaded the post in Gutenberg, I saw this 502 Bad Gateway error:

image

My educated hypothesis is that the error originates from the large include set; include gets translated to a very long query string which the server can't handle.

One idea is to introduce some middleware that gracefully batches a request with large include into multiple requests. However, this middleware would need to be sensitive to the order and orderby values too.

@danielbachhuber danielbachhuber added [Type] Bug An existing feature does not function as intended [Type] Enhancement A suggestion for improvement. REST API Interaction Related to REST API labels Nov 6, 2018
@danielbachhuber danielbachhuber added this to the WordPress 5.0 milestone Nov 6, 2018
@danielbachhuber danielbachhuber added [Package] Data /packages/data and removed [Type] Enhancement A suggestion for improvement. labels Nov 6, 2018
@dd32
Copy link
Member

dd32 commented Nov 7, 2018

Bad Gateway could also mean that it's PHP which has rejected the request (depending on how you've got the dev environment setup)

Apache and nginx would usually respond with a 414 Request-URI Too Large at (by default) ~4k or ~8k characters, but would probably be much lower in real-world production cases.

https://core.trac.wordpress.org/ticket/22757 also comes into play, where certain setups (suhosin) can limit individual query string lengths, core uses 128char as a safe value, as 512 characters is the default suhosin.get.max_value_length value.

@dd32
Copy link
Member

dd32 commented Nov 7, 2018

Looking at the included image, I'm thinking this is indeed a security extension limitation (or imitation of it) as the include string there (assuming 3-digit term id's) would be (100*3)+(99*3)=597 characters long (3 digit term ID + 3 character encoded comma).

If you were to take the core direction and limit it at 128char, with the above scenario you'd only be able to request 21 terms at once ((21*3)+(20*3)=123), or 85 terms at a 512char limit ((85*3)+(84*3)=507, and even less once you account for 4-digit term id's.

@paaljoachim
Copy link
Contributor

Hey Daniel @danielbachhuber and Dion @dd32
Please retest this issue with the newest version of WordPress and Gutenberg plugin to see if this is still an issue that needs to be fixed. Thanks!
How can we move it forward?

@watsefack
Copy link

Any news on this?
Crazy that this error still exists and there is no solution?

@markhowellsmead
Copy link

This issue is still relevant. PHP and server settings don't seem to be the problem, as I have the following configuration: max_input_vars=4000, memory_limit=256M, post_max_size=1000M.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Data /packages/data REST API Interaction Related to REST API [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

8 participants