gutenberg icon indicating copy to clipboard operation
gutenberg copied to clipboard

Issues when uploading images to a Gallery block: The response is not a valid JSON response.

Open nicolasmondada opened this issue 8 years ago • 47 comments

Problems when uploading images to a Gallery block

Steps to Reproduce (for bugs)

  1. Add a gallery block.
  2. Select 4-5 images (4-10Mb each) from your local drive and upload them.

Using Chrome 68.0.3440.106 + WP 4.9.8 + Gutenberg 3.5.0

Expected Behavior

Images should be uploaded to the gallery and displayed.

Current Behavior

Initially images seem to upload alright and a preview is shown on the gallery. A few seconds later an error message is displayed on the Gallery block: The response is not a valid JSON response.

Screenshots / Video

screen shot 2018-08-13 at 18 13 57 screen shot 2018-08-13 at 18 13 52

nicolasmondada avatar Aug 13 '18 17:08 nicolasmondada

Do you have any plugins installed that affect the API?

Are you able to check the Network tab in your browser developer tools to see if you can find an API call with an error and what the response is?

designsimply avatar Aug 14 '18 21:08 designsimply

It helped when I uploaded all the photos beforehand in the "Media" file. And then I was inserting them to gallery instead of uploading them directly to gallery interface.

klemenzagar91 avatar Aug 14 '18 22:08 klemenzagar91

Same issue

Karlheinzniebuhr avatar Aug 18 '18 00:08 Karlheinzniebuhr

Are you able to check the Network tab in your browser developer tools to see if you can find an API call with an error and what the response is?

designsimply avatar Aug 20 '18 22:08 designsimply

Running the Network tab from browser developer tools provided the following error

Name: Media Status: 500 Type: Fetch Initiator: VM1479:1

Screenshot:

2018-09-13-upload_image_json_error-network

Properties of the image I tried to upload:

Filename: 2017-08-25-High Trestle Bridge (7).jpg Size: 8.31 MB

Browser Properties:

Chrome Version 68.0.3440.106 (Official Build) (64-bit)

ktyfuller604 avatar Sep 13 '18 15:09 ktyfuller604

(I noted this on #9720 as well)

I am seeing the same error - "The response is not a valid JSON response" - when adding an image block and either choosing the upload dialog or dragging the image in.

When I try dragging the image straight into the editor, the image appears and flashes in and out. If I preview the post, the image shows. If I update and then view the published version the image is not there.

I have tried with multiple different images and all have the same result.

I am using FF Quantum 62.0.2 (64-bit).

GIF of what I am seeing: https://cld.wthms.co/XCDHZH

I am seeing a 500 error in the Network Monitor:

Request URL: https://test313036383.blog/wp-json/wp/v2/media
Request Method: POST
Status Code 500

Error in Network Monitor: https://cld.wthms.co/8udIkK

katiebethbrown avatar Sep 25 '18 16:09 katiebethbrown

@ktyfuller604 @katiebethbrown thank you for posting screenshots of the Network tab! I see that the media API returns a 500 error, but I can't see the response. There is something else I would like to check on though. Can you go to your Plugins page and install/activate the Health Check plugin and then go to Dashboard > Health Check > Debug and copy everything from the Server section into a reply here?

designsimply avatar Sep 27 '18 18:09 designsimply

Also wanted to add a quick note to say that I tested this using WordPress 4.9.8 and Gutenberg 3.9.0 and Firefox 62.0 on macOS 10.13.6 and image uploads to the gallery worked normally in my test. Here is the success response for the media call showing in my browser dev tools Network panel:

screen shot 2018-09-27 at 3 03 51 pm

The images were not large, they were about 1.9MB and 2.6MB respectively.

designsimply avatar Sep 27 '18 19:09 designsimply

Hey, @designsimply I did some additional testing:

  • A different site I have on the same account using the same image with the same version of Gutenberg (3.9.0) does not have the same issue. I've included server details for both sites.
  • I also tested to see if I added a text block first, then added the image does the error still occur (answer: yes)
  • I tried to get the response code from the Media API for you, but it says "This request has no response data available".

Server Details for Site with the Error (Gutenberg 3.9.0, WordPress Version 4.9.8)

Server architecture Linux 4.9.0-8-amd64 x86_64
PHP Version 7.0.31 (Supports 64bit values)
PHP SAPI fpm-fcgi
PHP max input variables 6144
PHP time limit 1200
PHP memory limit 256M
Max input time 1200
Upload max filesize 2047M
PHP post max size 2047M
cURL Version 7.61.0 OpenSSL/1.1.0f
SUHOSIN installed No
Is the Imagick library available No

Server details for the site that does not have the error (Gutenberg 3.9.0, WordPress Version 4.9.8)

Server architecture Linux 4.9.0-7-amd64 x86_64
PHP Version 7.0.31 (Supports 64bit values)
PHP SAPI fpm-fcgi
PHP max input variables 6144
PHP time limit 1200
PHP memory limit 256M
Max input time 1200
Upload max filesize 2047M
PHP post max size 2047M
cURL Version 7.61.0 OpenSSL/1.1.0f
SUHOSIN installed No
Is the Imagick library available No

I hope this helps!

ktyfuller604 avatar Sep 28 '18 13:09 ktyfuller604

All right, so it looks like both the working setup and the non-working setup have exactly the same max filesize settings. 🤔

The next level will be to check the server error logs for any related errors that show up there at the time the problem happens. I searched and found an article that has some tips about how to do that at https://www.1and1.com/cloud-community/learn/web-server/server-management/how-to-fix-http-error-code-500-internal-server-error/

A similar problem was reported in #9142 and the error logs revealed a problem with upload_is_user_over_quota() and a fix was already patched in the core WordPress project (core/43462), see https://github.com/WordPress/gutenberg/issues/9142#issuecomment-417435856. And if the same error is showing in your server error logs then that patch should be the fix, but if you see a different error then we'll need to continue debugging.

designsimply avatar Sep 28 '18 19:09 designsimply

Since the Gutenburg update I'm also seeing this issue on my Wordpress site. No image uploads will work.

benbowler avatar Sep 29 '18 08:09 benbowler

@designsimply Here's what I'm seeing in the server section from Health Check:

### Server ###

Server architecture: Linux 4.9.0-7-amd64 x86_64
PHP Version: 7.0.31 (Supports 64bit values)
PHP SAPI: fpm-fcgi
PHP max input variables: 6144
PHP time limit: 1200
PHP memory limit: 256M
Max input time: 1200
Upload max filesize: 2047M
PHP post max size: 2047M
cURL Version: 7.61.0 OpenSSL/1.1.0f
SUHOSIN installed: No
Is the Imagick library available: No

There is no response listed, but these are the Response Headers:

access-control-allow-headers: Authorization, Content-Type
access-control-expose-headers: X-WP-Total, X-WP-TotalPages
cache-control: no-cache, must-revalidate, max-age=0
content-type: application/json; charset=UTF-8
date: Sun, 30 Sep 2018 01:02:22 GMT
expires: Wed, 11 Jan 1984 05:00:00 GMT
link: <https://test313036383.blog/wp-json/>; rel="https://api.w.org/"
p-lb: lb1.q1.sat
p-ws: web118.q10.sat
server: nginx
status: 500
strict-transport-security: max-age=86400
x-ac: 3.sea _proxy_upstream_1
x-content-type-options: nosniff
x-robots-tag: noindex
x-wp-nonce: c09e9aecfc

Screenshot of the Response Headers as well: https://cld.wthms.co/EwIbIh

I also noted that I was able to upload the image to the media library and add it from there without issue.

I tried uploading the image from the photo block in the post from two different machines (Mac and Chromebook) and with and without a proxy server and had the same result in all situations. It appears as if it is timing out.

katiebethbrown avatar Sep 30 '18 01:09 katiebethbrown

I have done a bit more troubleshooting and I think I have this narrowed down. I was able to upload the image to the image block in the post without issue when I used Troubleshooting mode in the Health Check plugin and turned just Gutenberg back on.

So I returned to normal operation and tried deactivating plugins one by one.

Once I deactivate WooCommerce the image adds without a problem. When I reactivate WooCommerce I get the error again.

@ktyfuller604 Any chance you could try deactivating Woo and see if you see the same behavior?

katiebethbrown avatar Sep 30 '18 01:09 katiebethbrown

One more thing to note. I tried this in Firefox today (with WooCommerce re-activated to cause the error to occur) out of curiosity, and see this in the Response area of the Network tab when the media item with the 500 error is selected:

SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data

Screenshot: http://cld.wthms.co/zRppPC

katiebethbrown avatar Sep 30 '18 22:09 katiebethbrown

@katiebethbrown You are definitely on to something. I deactivated Woo and could add an image without error, immediately reactivated, tried again, got the JSON error again.

ktyfuller604 avatar Sep 30 '18 23:09 ktyfuller604

Hello. I have several issues. I can't add an image/video neither by drag and drop, neither by upload. I have the message "The response is not a valid JSON response." I use a multisite installation with several plugins and themes, but with 280 sites I can't deactivate plugins. I will try on a local installation when I will have time.

Another issue is about embed media. It is impossible with videos from https://tube.ac-lyon.fr The error message is (in French) : "Désolé, il est impossible d’embarquer ce contenu." But it is possible by the classic way (without Gutenberg).

vfavrat avatar Oct 05 '18 09:10 vfavrat

With a 500 status response, it is often going to be a PHP error. Can any of you experiencing the issue check the PHP error log after triggering the error to see what it might be showing?

earnjam avatar Oct 15 '18 13:10 earnjam

@earnjam I'm in FF. Where can I find the PHP error log? Let me know and I can pass along what I see there.

katiebethbrown avatar Oct 15 '18 18:10 katiebethbrown

@earnjam I'm in FF. Where can I find the PHP error log? Let me know and I can pass along what I see there.

It would be on the web server rather than in the browser. Looks like your site you mentioned earlier in the thread might be on wordpress.com, so not sure if you can get to that.

We'll probably need one of the others in the thread who is self-hosted to let us know. I'll try to recreate the issue using WooCommerce though.

earnjam avatar Oct 15 '18 20:10 earnjam

Hi @earnjam. I did a bit of digging, and I am seeing the following PHP error each time I try to add an image:

PHP Fatal error: Cannot redeclare add_settings_error() (previously declared in /wordpress/plugins/wpcomsh/2.3.30/vendor/automattic/wc-calypso-bridge/inc/wc-calypso-bridge-mailchimp-add-settings-error.php:25) in /wordpress/core/4.9.8/wp-admin/includes/template.php on line 1418

It may be somehow related to this: https://github.com/Automattic/wc-calypso-bridge/issues/55 which also throws this error doing some sort of image processing when WooCommerce is installed (though that issue seems to be unrelated to Gutenberg).

katiebethbrown avatar Oct 16 '18 00:10 katiebethbrown