A partial archive of https://discourse-mediawiki.wmflabs.org as of Saturday May 21, 2022.

Copyuploadbaddomain error code while using API:Upload

Mansi29ag

I am writing code for testing API:Upload such that the file to be uploaded if at some URL. I am testing code using https://test.wikipedia.org/w/api.php test API, but for most of the urls I am getting the following error.

{‘servedby’: ‘mw1224’, ‘error’: {‘code’: ‘copyuploadbaddomain’, ‘info’: ‘Uploads by URL are not allowed from this domain.’, ‘*’: ‘See https://test.wikipedia.org/w/api.php for API usage. Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce> for notice of API deprecations and breaking changes.’}}

and for some urls I am getting the following error-

{‘servedby’: ‘mw1315’, ‘error’: {‘info’: ‘This action has been automatically identified as harmful, and therefore disallowed. If you believe your action was constructive, please inform an administrator of what you were trying to do. A brief description of the abuse rule which your action matched is: 0 copyvios’, ‘code’: ‘abusefilter-disallowed’, ‘abusefilter’: {‘id’: 162, ‘description’: ‘0 copyvios’, ‘actions’: [‘disallow’]}, ‘*’: ‘See https://test.wikipedia.org/w/api.php for API usage. Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce> for notice of API deprecations and breaking changes.’, ‘warning’: ‘This action has been automatically identified as harmful, and therefore disallowed.\nIf you believe your action was constructive, please inform an administrator of what you were trying to do.\nA brief description of the abuse rule which your action matched is: 0 copyvios’, ‘message’: {‘key’: ‘abusefilter-disallowed’, ‘params’: [‘0 copyvios’, 162]}, ‘filekey’: ‘16g1tlns6obo.3k7abc.42588.’, ‘sessionkey’: ‘16g1tlns6obo.3k7abc.42588.’}}

How to solve this problem?

aklapper

https://noc.wikimedia.org/conf/InitialiseSettings.php.txt defines in ‘wgCopyUploadsDomains’ that for testwiki only uploads from flickr.com, staticflickr.com and upload.wikimedia.org are allowed.

To solve this problem, either use the aforementioned three domains to upload from, or use whatever domains you prefer to test on your own MediaWiki installation somewhere.

Tgr

You can inspect the abuse filter rules at <wiki domain>/wiki/Special:AbuseFilter/<filter id>, so https://test.wikipedia.org/wiki/Special:AbuseFilter/162 in this case. (Some filter rules are non-public, but those are for catching specific malicious changes and you are unlikely to run into them.) You’ll just have to adapt your behavior to not match the filters (in this case, the easiest is to just make a couple edits).

Mansi29ag

Thanks! I am able to do it with staticflickr.com.

aklapper

What exactly does not work? Do you still get a copyuploadbaddomain error? Or only the abusefilter error?

Mansi29ag

No, sorry Its working for staticflickr. It failed with flickr and upload.wikimedia.