Last modified: 2013-05-09 14:30:30 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"}}
"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.
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?
(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".
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?
(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.