Page MenuHomePhabricator

Pywikibot: imagetransfer: breaks if upload-by-URL enabled, but not for the URL in question
Closed, ResolvedPublic

Description

If you try to use imagetransfer.py to copy a file from Commons to Wikisource, it will fail with API error copyuploadbaddomain

This is because although the target wiki has URL uploads on, the URL in question isn't OK. However, if it had URL uploading disabled entirely (or the user didn't have the rights to use it), it would happily download and re-upload.

ignore_warnings = self.ignore_warning is True or self._handle_warnings
if '://' in file_url and not site.has_right('upload_by_url'):
    try:
        file_url = self.read_file_content(file_url)
    except FatalServerError:
        return None

This should probably fall back to the download/re-upload method if the upload-by-URL fail due to copyuploadbaddomain.

See also T294824

Event Timeline

Can you provide a sample or command line which breaks for debugging?

The command reported was python3 scripts/imagetransfer.py File:Van_Dyck_and_portrait_engraving_and_etching_in_the_seventeenth_century_\(IA_vandyckportraite00hind\).pdf -keepname -force_if_shared -tosite:wikisource:en -site:commons:commons -always -user:sDrewthbot

Change 736417 had a related patch set uploaded (by Xqt; author: Xqt):

[pywikibot/core@master] [IMPR] Retry upload if 'copyuploadbaddomain' API error occurs

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

Xqt triaged this task as Medium priority.
Inductiveload renamed this task from Pywikibot: imagetranfer: breaks if upload-by-URL enabled, but not for the URL in question to Pywikibot: imagetransfer: breaks if upload-by-URL enabled, but not for the URL in question.Nov 3 2021, 1:34 PM

Change 736417 merged by jenkins-bot:

[pywikibot/core@master] [IMPR] Retry upload if 'copyuploadbaddomain' API error occurs

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