Page MenuHomePhabricator

"A file with name "$1" already exists in the shared file repository, and cannot be overwritten" shows up while trying to rename a file with single letter which is different from standard format
Closed, ResolvedPublic0 Estimated Story Points

Description

Steps to reproduce:

  1. Go to Media upload dialog
  2. Select an image and click on "Upload"
  3. Now in the Details section rename the file name to "a" and click on "Save"
  4. An error message comes up "A file with name "$1" already exists in the shared file repository, and cannot be overwritten."

instead of
"Filename has been changed to "a.png"

Screen Shot 2015-10-19 at 4.11.53 PM.png (447×517 px, 40 KB)

Related Objects

Event Timeline

Ryasmeen raised the priority of this task from to Needs Triage.
Ryasmeen updated the task description. (Show Details)
Ryasmeen added a project: VisualEditor.
Ryasmeen subscribed.
Jdforrester-WMF updated the task description. (Show Details)
Jdforrester-WMF added a project: Multimedia.
Jdforrester-WMF set Security to None.

Change 285401 had a related patch set uploaded (by Matthias Mullie):
Fall back to API error msg when msg params are needed

https://gerrit.wikimedia.org/r/285401

Apart from the error message that is obviously flawed (includes an unparsed $1), was this behaviour also incorrect?

Apart from the error message that is obviously flawed (includes an unparsed $1), was this behaviour also incorrect?

^^ Who could answer that question? (Or review Matthias' patch?)

I think the only problem is that the $1 isn't included. I'm looking at the patch now.

MarkTraceur changed the task status from Open to Stalled.Dec 6 2016, 4:53 PM
MarkTraceur added a project: Language-Team.

@MarkTraceur What are you asking from the Language team?

I believe a review of https://gerrit.wikimedia.org/r/#/c/285401/
It's about how to deal with API responses to have a (i18n) error code & description, but no i18n params (e.g. fileexists-shared-forbidden in ApiBase::$messageMap)
In such case, we'd fall back to the (English) server-provided description instead of trying to parse/i18n on the client side.

However, I saw that API error output is being refactored (T47843: Rework API error reporting) and a huge patch (https://gerrit.wikimedia.org/r/#/c/321406/) landed yesterday.
I assume we'll be able to put this workaround to rest after this refactor, but haven't looked at it in great detail.

However, I saw that API error output is being refactored (T47843: Rework API error reporting) and a huge patch (https://gerrit.wikimedia.org/r/#/c/321406/) landed yesterday.
I assume we'll be able to put this workaround to rest after this refactor, but haven't looked at it in great detail.

You should be able to, yes. The general outline would be to include uselang, errorformat (probably =html, although there are other options), and probably errorsuselocal in your query and adjust the error and warning handling for the new format.

The new-format output would look something like this, if you also include formatversion=2:

{
    "errors": [
        {
            "code": "fileexists-shared-forbidden",
            "html": "<p>A file with this name exists already in the shared file repository.\nIf you still want to upload your file, please go back and use a new name.\n</p>\n<div class=\"center\"><div class=\"thumb tnone\"><div class=\"thumbinner\" style=\"width:174px;\"><a href=\"/wiki/File:Example.jpg\" class=\"image\"><img alt=\"\" src=\"https://upload.wikimedia.org/wikipedia/commons/a/a9/Example.jpg\" width=\"172\" height=\"178\" class=\"thumbimage\" /></a>  <div class=\"thumbcaption\"><div class=\"magnify\"><a href=\"/wiki/File:Example.jpg\" class=\"internal\" title=\"Enlarge\"></a></div>example.jpg</div></div></div></div>\n",
            "data": {
                "filekey": "14idovw9uo7c.ud8i4v.1.txt",
                "sessionkey": "14idovw9uo7c.ud8i4v.1.txt",
                "invalidparameter": "filename"
            },
            "module": "upload"
        }
    ],
    "docref": "See http://localhost/w/api.php for API usage."
}

If you'd rather get the message key and params to handle yourself for some reason, errorformat=raw will do that for you:

{
    "errors": [
        {
            "code": "fileexists-shared-forbidden",
            "key": "fileexists-shared-forbidden",
            "params": [
                "example.jpg"
            ],
            "data": {
                "filekey": "14idozhhhdh4.xegsfq.1.txt",
                "sessionkey": "14idozhhhdh4.xegsfq.1.txt",
                "invalidparameter": "filename"
            },
            "module": "upload"
        }
    ],
    "docref": "See http://localhost/w/api.php for API usage."
}

I removed Language-Team, but I'm subscribed.

Change 326134 had a related patch set uploaded (by Matthias Mullie):
[WIP] Simplify error handling

https://gerrit.wikimedia.org/r/326134

Change 285401 abandoned by Matthias Mullie:
Fall back to API error msg when msg params are needed

Reason:
No longer needed with https://gerrit.wikimedia.org/r/#/c/331232/

https://gerrit.wikimedia.org/r/285401

Jdforrester-WMF changed the point value for this task from 1 to 0.Feb 2 2017, 7:03 PM