Automattic / Automattic/jetpack
Error handling for failed API uploads
- Dominant language
- PHP
- Stars
- 1.8k
- Forks
- 898
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 774
Description
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](https://github.com/Automattic/jetpack/blob/42b43280d6e316719d90a534b6eb8e63540ba091/class.jetpack.php#L3497) 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,
)
```
Contributor guide
Research direction
Start at class.jetpack.php around line 3497 and inspect how failed uploads are handled before the HMAC check. Reproduce an oversized image upload through the wp.com API using the issue's `$file` values, then verify that the resulting error reflects the upload failure rather than reporting an HMAC mismatch.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100