drupal-graphql / graphql

GraphQL integration for Drupal 9/10
288 stars 201 forks source link

"An unrecoverable error occurred. The uploaded file likely exceeded the maximum file size (1000 MB) that this server supports" When selecting schema for new server #1350

Closed thursdaybw closed 1 year ago

thursdaybw commented 1 year ago

I have a fresh install of Drupal 10.1.2 using the standard profile in a lando environment, and I have installed the Graphql module via composer.

I have followed the first 3 steps on the handbook and been stuck on step 3 "You can use the "Example schema" that comes with the graphql_examples module (comes with the graphql module but needs to be enabled separately) to try out using GraphQL for the first time before making your own schema. " however when I change the selection in the select box I get the following error An unrecoverable error occurred. The uploaded file likely exceeded the maximum file size (100 MB) that this server supports. I modified my php.ini in an attempt to resolve the upload issue, but it just did this: An unrecoverable error occurred. The uploaded file likely exceeded the maximum file size (1000 MB) that this server supports. .

Why is this select box even triggering a file upload? I have watched the network tab in developer tools and reloaded the page but there are no network calls listed there, but I can see the failed POST request in the console.

This is what I am seeing in my browser: image

image

I changed the values of post_max_size and upload_max_filesize from 100M to 1000M

php -i |grep -E "upload_max_filesize|post_max_size"       
post_max_size => 1000M => 1000M
upload_max_filesize => 1000M => 1000M

I'm stumped. but as this is a fresh install of drupal and graphql is the only contrib module installed it seems qutie strange.

Are there base requirements for these PHP settings?:

upload_max_filesize="1000M"
post_max_size="1000M"

This is the part of the graphql book I am attempting to follow, stumpted before I even start it seems :) image

Can someone suggest a workaround so I can create a server and move on?

thursdaybw commented 1 year ago

I have been doing a little digging, checked the PHP logs (bright idea lol).

So, PHP is throwing this error:

I haven't worked out yet how/why $debug_flags is an array on the ajax request, but an INT (0) on a page load. I got that it the property name retrieved from the $server is singular (debug_flag) versus the variable being plural (debug_flags), $server->get('debug_flag') ?? 0;.. Which is is a bool or a list? I don't know yet, I just wanted to look at the example working, here' I am in Katmandu with a yak a razor :)

image

thursdaybw commented 1 year ago

LOL it's right there in front of my face why it returns and array on the subsequent call, it literally sets it to an array right there on my breakpoint.

OK.. I'm not in a position to formulate a full patch right now, but here's my little fix:

replace $debug_flags = intval($server->get('debug_flag')) ?? 0; with:

    $debug_flags_array = $server->get('debug_flag');
    $debug_flags = 0;
    if (is_array($debug_flags_array)) {
      // Convert array of selected options back into bitwise flags
      foreach ($debug_flags_array as $flag) {
        $debug_flags |= $flag;
      }
    }

Since $debug_flags is being used as a bitwise flag, it should remain an integer. But when the form is submitted, Drupal returna an array of selected options. This is causing the conflict when $server->get('debug_flag') returns an array after the form has been submitted.

My code convert the array back into the bitwise flags.

thursdaybw commented 1 year ago

Pull request: https://github.com/drupal-graphql/graphql/pull/1352