Automattic / jetpack

Security, performance, marketing, and design tools — Jetpack is made by WordPress experts to make WP sites safer and faster, and help you grow your traffic.
https://jetpack.com/
Other
1.58k stars 797 forks source link

Error handling for failed API uploads #3400

Open koke opened 8 years ago

koke commented 8 years ago

When you try to upload an image through the wp.com API and it's too large (larger than the site's max_upload_filesize), it will fail with an error that doesn't seem relevant:

The corresponding HMAC for this file does not match

The error is coming from here and it's caused because it doesn't check if the uploaded file failed. Inspecting $file on a failed upload shows this:

array (
  'name' => 'img_0008.jpg',
  'type' => '',
  'tmp_name' => '',
  'error' => 1,
  'size' => 0,
)
SergioEstevao commented 7 years ago

I will also add that if we try to upload a video and the user does not have VideoPress activated on his jetpack plan, and the file size is larger than the site limit we get this error: 'An unknown problem occurred processing the upload on the Jetpack site'

If you disable jetpack and use directly XML-RPC on the site you see a more user friendly error message like this: Could not write file AAA.mp4 (This file is too big. Files must be less than 2048 KB in size

stale[bot] commented 6 years ago

This issue has been marked as stale. This happened because:

No further action is needed. But it's worth checking if this ticket has clear reproduction steps and it is still reproducible. Feel free to close this issue if you think it's not valid anymore — if you do, please add a brief explanation.

designsimply commented 4 years ago

I double checked the theory where max_upload_filesize was set too small and found that a proper message was displayed in that case and I did not see the error "The corresponding HMAC for this file does not match".

My testing steps:

  1. Create a .user.ini in the WordPress root directory with upload_max_filesize = 1M.
  2. Go to /wp-admin/media-new.php in a browser and verify it says "Maximum upload file size: 1 MB."
  3. Go to Media in the app and try to upload an image.

Result: the media upload fails with error "Files exceeds the maximum upload size for …" as expected. (35s)

file-exceeds-the-maximum-upload-size-wpandroid-13 5-rc-1

Tested with WPAndroid 13.5-rc-1 on Pixel 3 Android 10 using honest-spiders.jurassic.ninja with upload_max_filesize set to 1M and with the Jetpack active and connected as wpcom user design5279.

When I tried to upload a video that exceeded the max upload filesize, I got a more generic error that said, "We couldn't complete this action." (16s)

we-couldnt-complete-this-action

Tested with WPAndroid 13.5-rc-1 on Pixel 3 Android 10 using honest-spiders.jurassic.ninja with upload_max_filesize set to 1M and with the Jetpack active and connected as wpcom user design5279.

@SergioEstevao does the incorrect error message for when videos are uploaded above the max file size limit need to be changed at the API level or in the app?

SergioEstevao commented 4 years ago

@designsimply it can be a combination of both, I don't know the details on the Android app, are you seeing the same message for videos in the iOS app?

stale[bot] commented 4 years ago

This issue has been marked as stale. This happened because:

No further action is needed. But it's worth checking if this ticket has clear reproduction steps and it is still reproducible. Feel free to close this issue if you think it's not valid anymore — if you do, please add a brief explanation.