Page MenuHomePhabricator

Return meaningful error message when users try to import a file with a forbidden file type
Closed, ResolvedPublic2 Estimated Story Points

Description

Bug Report

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

illegal_extension.png (336×739 px, 16 KB)

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. The allowed extensions are: <comma delimited extension list>. Visit the <help page>

Screen Shot 2020-01-02 at 2.46.34 AM.png (508×1 px, 112 KB)

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

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).

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.

Change 561388 had a related patch set uploaded (by Ammarpad; owner: Ammarpad):
[mediawiki/extensions/FileImporter@master] Return more precise error for forbideen extensions

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

Ammarpad raised the priority of this task from Lowest to Medium.

That would be really nice for users, but problematic when using the extension on sites other than Commons. We should probably include this help link by overriding the system message.

Change 561388 merged by jenkins-bot:
[mediawiki/extensions/FileImporter@master] Return more precise error for forbidden extensions

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

Change 563680 had a related patch set uploaded (by Thiemo Kreuz (WMDE); owner: Thiemo Kreuz (WMDE)):
[mediawiki/extensions/FileImporter@master] Streamline error checking and reporting in ImportPlanValidator

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

thiemowmde moved this task from Incoming to In QWERTY sprint on the archived--TCB-Team board.
thiemowmde set the point value for this task to 2.
thiemowmde moved this task from Sprint Backlog to Review on the WMDE-QWERTY-Sprint-2020-01-08 board.
WMDE-Fisch moved this task from Demo to Done on the WMDE-QWERTY-Sprint-2020-01-08 board.

Validated locally.