Page MenuHomePhabricator

Return meaningful error message when users try to import a file with a forbidden file type
Open, LowestPublic

Description

Bug Report
When trying to import a file type not allowed by the target wiki's $wgFileExtensions, the error dialog looks like:

This is misleading, as we *do* know what the error is, and there's no way to correct it by changing the file's title.

Acceptance Criteria
[] If a file's file type is not allowed on the target wiki, go straight to the "hard" error page and show the following error message: You're trying to import a file with the extension <extension name>. This file type is not allowed in this wiki.

Note
This is an issue for non-Wikimedia wikis using the file importer. The Wikimedia wikis all have the same file type acceptance criteria.

Event Timeline

awight created this task.May 8 2019, 11:17 AM
thiemowmde triaged this task as Lowest priority.May 14 2019, 1:38 PM
thiemowmde added a subscriber: thiemowmde.

We figured this is not relevant in the Wikimedia environment, because all our wikis allow the same file types. There is no way a file can show up with an extension that is not allowed on Commons.

However, this can easily happen in 3rd-party installations. The code should be sane and helpful. But we (WMDE) should not invest to much on this, and not implement to many special cases we are not going to need (YAGNI).

Pikne added a subscriber: Pikne.May 14 2019, 3:11 PM

We figured this is not relevant in the Wikimedia environment, because all our wikis allow the same file types. There is no way a file can show up with an extension that is not allowed on Commons.

Actually there are some files with prohibited file types, uploaded either before given file type became prohibited, or uploaded with wrong (allowed) file extension. E.g. English Wikipedia currently has 67 bmp files (media statistics). Though, I agree that this issue probably still isn't of high priority.

My suggestion for the error message: You're trying to import a file with the extension <extension name>. This file type is not allowed in this wiki.
Ideally, we would link to a list of allowed file types. Is there a default place in MediaWiki installations that defines this? (I'm thinking of a manual, i.e. something more reader-friendly than $wgFileExtensions)

@Lea_WMDE If I understand this correctly, the whole field for "new file name" makes no sense in this scenario, because I'm not able to fix this situation at all. Correct? Shouldn't we remove the field in this case?

You're trying to import a file with the extension <extension name>. This file type is not allowed in this wiki.

sounds good. I wonder if it should not be "This file extension is not allowed…" to be consistent.

I'm thinking of a manual, i.e. something more reader-friendly than $wgFileExtensions)

To understand the message above, people need to be familiar with what a file extension is, anyway, so I think the data in $wgFileExtensions is not bad (and always up-to-date). We need to render it, something like this:

The allowed extensions are: jpg, png, avi, ogg

In case the list is super long, we indeed should link somewhere.

ideally it would recognize the general type (image, sound, video) and would say: "You tried to upload a video with the extension .mp4 . This extension is not allowed on this wiki. Allowed video formats are: …"—but this is beyond MVP.

@Lea_WMDE If I understand this correctly, the whole field for "new file name" makes no sense in this scenario, because I'm not able to fix this situation at all. Correct? Shouldn't we remove the field in this case?

This is correct, it's unrecoverable.

You're trying to import a file with the extension <extension name>. This file type is not allowed in this wiki.

sounds good. I wonder if it should not be "This file extension is not allowed…" to be consistent.

My thought behind this was that if people don't know what a file extension is, they learn that it determines the file type in the next sentence.

Lea_WMDE renamed this task from Vague error message when importing illegal file extension to Return meaningful error message when users try to import a file with a forbidden file type.May 29 2019, 6:27 AM
Lea_WMDE updated the task description. (Show Details)

When I need to know the file types a wiki accepts, I typically check https://commons.wikimedia.org/wiki/Special:Upload. It currently says:

Permitted file types: tiff, tif, png, gif, jpg, jpeg, webp, xcf, mid, ogg, ogv, svg, djvu, stl, oga, flac, opus, wav, webm, mp3.

We can easily do the same and just list all extensions.

A good help page to link to is https://commons.wikimedia.org/wiki/Commons:File_types.

Note it's not easy, probably even impossible to detect a general type (e.g. video). To do this, we need to know the file extension and what it represents. But the issue we are dealing with here are unknown file extensions. We could hard-code a few known but not accepted extensions, e.g. widely used video formats we can not accept for legal reasons, and show a much nicer error message for them. But this is probably way out of scope of this extension, even for a version 2.