Last modified: 2013-05-09 14:30:30 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T50261, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 48261 - Uploading a file with a bad filename doesn't report an error it reports a warning
Uploading a file with a bad filename doesn't report an error it reports a war...
Status: RESOLVED INVALID
Product: MediaWiki
Classification: Unclassified
API (Other open bugs)
unspecified
All All
: Unprioritized normal (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-05-08 15:25 UTC by Jon
Modified: 2013-05-09 14:30 UTC (History)
7 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Jon 2013-05-08 15:25:16 UTC
A photo doesn't get uploaded when you give a bad filename but for some reason it gives a warning.

{"upload":{"result":"Warning","warnings":{"badfilename":"Test_2013-05L-08_08-22.JPG"},"filekey":"11f0ht8dgbxg.ajqpua.1.jpg","sessionkey":"11f0ht8dgbxg.ajqpua.1.jpg"}}

Expected:
"upload":{"result":"error","error":{"badfilename":"Test_2013-05L-08_08-22.JPG"},"filekey":"11f0ht8dgbxg.ajqpua.1.jpg","sessionkey":"11f0ht8dgbxg.ajqpua.1.jpg"}}
Comment 1 Brad Jorsch 2013-05-08 15:51:10 UTC
"badfilename" isn't an error, it's a warning that the filename you specified is going to be stored under a different name than you specified. And it doesn't prevent uploading any more than any other warning: If you specify ignorewarnings in your API query, the file *does* get uploaded.

This is just like uploading through the Special:Upload web UI: when warnings exist, the file is temporarily stashed and warnings are displayed to the user. But if wpUploadIgnoreWarning is included in the submission (via the "Ignore any warnings" checkbox or the "Ignore warning and save file anyway" submit button), the file is uploaded despite any warnings.
Comment 2 Jon 2013-05-08 16:51:06 UTC
As a frontend developer all I can say is this is extremely dumb and in my opinion not how an API should work. I haven't included wpUploadIgnoreWarning so an error has occurred.

Definition of warning: "A statement or event that indicates a possible or impending danger, problem, or other unpleasant situation."

Here it is not possible or impending. My photo didn't get uploaded. It wasn't successful.

How does this make sense to a new developer using our api for the first time?
Comment 3 Brad Jorsch 2013-05-08 19:08:00 UTC
(In reply to comment #2)
> Here it is not possible or impending. My photo didn't get uploaded. It wasn't
> successful.

Which is why the result is not "Success".
Comment 4 Jon 2013-05-09 01:20:08 UTC
The goal of this query is to put a file on the server and if it fails due to a bad filename error when I don't provide wpUploadIgnoreWarning then that goal has not succeeded.

If a file is uploaded that is a duplicate that is a warning. The file is on the server so it makes sense.

Brad you are still failing to explain to me in a way I understand why this is a warning and not an error. This makes no sense to me and I'm sure makes no sense to others...

At the moment in general I feel like when I query the API I get success, failure or "magical mystery box" which could be either and I have to know every possible outcome to understand whether the photo ended up on the server or not. Why can this not be binary?
Comment 5 Brad Jorsch 2013-05-09 14:30:30 UTC
(In reply to comment #4)
> Brad you are still failing to explain to me in a way I understand why this
> is a warning and not an error.

Because the "badfilename" message is not an error. It's a (poorly-named, but that's what we are given by UploadBase) warning that the name you supplied is not the name that is going to be used, but MediaWiki will happily allow the upload using the corrected name if you tell it to. Just like "duplicate" is a warning that the file is a duplicate, but MediaWiki will happily allow the upload anyway if you tell it to.

> At the moment in general I feel like when I query the API I get success,
> failure or "magical mystery box" which could be either and I have to know
> every
> possible outcome to understand whether the photo ended up on the server or
> not.
> Why can this not be binary?

It's very simple: Look at the "result" field in the response. If it's "Success", the upload succeeded. If not, something went wrong and it's up to your application to provide proper handling of that situation because MediaWiki *cannot* correctly do it for you.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links