Topic: [Bug/Confirmed] (Issue #621/#627) 500 error when when file parameter during upload is wrong type.

Posted under Site Bug Reports & Feature Requests

Bug overview description.
When I'm trying to upload an image via API I get error 500

What part(s) of the site page(s) are affected?
API, post/create

What is the expected behavior?
Successful upload or some kind of meaningful error

What actual behavior is given instead?
Image is not uploaded and no meaningful error in response

Time of incident (if applicable).
Should be a bunch of requests made today

Can you reproduce the bug every time?
Yes

What steps did you take to replicate this bug?

What I send (response from httpbin)
{
  "args": {}, 
  "data": "", 
  "files": {}, 
  "form": {
    "login": "Jazz", 
    "password_hash": "butt", 
    "post[file]": "http://d.facdn.net/art/phlegraofmystery/1463623236/1463623236.phlegraofmystery_bunnycaptainfuraffinity.png", 
    "post[rating]": "s", 
    "post[tags]": "PhlegraOfMystery bunny solo female clothed ranged_weapon"
  }, 
  "headers": {
    "Accept": "*/*", 
    "Content-Length": "712", 
    "Content-Type": "multipart/form-data; boundary=------------------------bcc3708b5d6a55a2", 
    "Host": "www.httpbin.org", 
    "User-Agent": "curl/7.49.0"
  }, 
  "json": null, 
  "origin": "butt", 
  "url": "http://www.httpbin.org/post"
}

If I send incorrect API key I get "access denied" error so request doesn't seem to be malformed

Errors or other messages returned (if any).
Error 500 with fields

success: false
reason: Unexpected error (8ccefff4ee8229d8f51d4e52625cf43c)

Text inside parenthesis varies from image to image, if I try to upload not from URL but from disk, there's no text inside parenthesis

Updated by KiraNoot

I'm relating this to issue #621 the meta issue for uploading issues and upload error reporting. This particular issue has been assigned internal bug ID #627.

In this case the upload failed because a string/url was used in the file field, when a proper file was expected and it isn't being properly accounted for.

Updated by anonymous

Hmm, yeah, I've misread the API docs on parameters and used the wrong parameter when uploading from URL

Just to clarify, if I send an actual file in post[file], it still doesn't work (or I'm still doing something wrong)

If I send

{
  "args": {}, 
  "data": "", 
  "files": {
    "post[file]": "data:application/octet-stream;base64,iVBORw0KGgoAAAANSU... basically the image"
  }, 
  "form": {
    "login": "Jazz", 
    "password_hash": "butt", 
    "post[rating]": "s", 
    "post[tags]": " solo female clothed bunny solo phlegraofmystery ranged_weapon"
  }, 
  "headers": {
    "Accept": "*/*", 
    "Content-Length": "75053", 
    "Content-Type": "multipart/form-data; boundary=------------------------c08d1652717492b1", 
    "Host": "www.httpbin.org", 
    "User-Agent": "curl/7.49.0"
  }, 
  "json": null, 
  "origin": "butt", 
  "url": "http://www.httpbin.org/post"
}

I get:

{"success":false,"reason":"Unexpected error ([empty])"}

Neither does it work when I use the correct? field to upload via URL, e.g. I send

{
  "args": {}, 
  "data": "", 
  "files": {}, 
  "form": {
    "login": "Jazz", 
    "password_hash": "butt", 
    "post[rating]": "s", 
    "post[tags]": " solo female clothed bunny solo phlegraofmystery ranged_weapon", 
    "post[upload_url]": "http://d.facdn.net/art/phlegraofmystery/1463623236/1463623236.phlegraofmystery_bunnycaptainfuraffinity.png"
  }, 
  "headers": {
    "Accept": "*/*", 
    "Content-Length": "848", 
    "Content-Type": "multipart/form-data; boundary=------------------------86d54c1e9c969474", 
    "Host": "www.httpbin.org", 
    "User-Agent": "curl/7.49.0"
  }, 
  "json": null, 
  "origin": "butt", 
  "url": "http://www.httpbin.org/post"
}

I get

{"success":false,"reason":"Unexpected error (2a84f7759b650645cd8e0d622421a140)"}

Updated by anonymous

You actually uncovered another bug with the upload by url option you tried second. Which is that you need to include all of the parameters that are in the form, even if they are empty. The lack of 'source' parameter caused another exception.

The first is related to a file that couldn't be parsed.

Updated by anonymous

  • 1