Page MenuHomePhabricator

interface-admin cannot edit sitewide CSS/JS/JSON files via API
Closed, InvalidPublic

Description

Consider the following Python 3 script:

from requests import Session

lgname = 'Dalba@Dalba'
lgpassword = '<redacted>'
url = "https://fa.wikipedia.beta.wmflabs.org/w/api.php"

session = Session()

query_response = session.get(url + '?action=query&meta=tokens&type=login&format=json')
login_response = session.post(url, data={
    'action':"login",
    'lgname':lgname,
    'lgpassword':lgpassword,
    'lgtoken':query_response.json()['query']['tokens']['logintoken'],
    'format':"json",
})
assert login_response.json()['login']['result'] == 'Success'

csrftoken = session.post(url, b'action=query&meta=tokens&format=json').json()['query']['tokens']['csrftoken']

edit_response = session.post(url, data={
    'action': 'edit',
    'title': 'Mediawiki:Test.js',
    'text': '',
    'summary': 'test',
    'format': 'json',
    'token': csrftoken
})
print(edit_response.json())

The edit fails with the following response:

{'error': {'code': 'interfaceadmin-info', 'info': 'Editing of sitewide CSS/JS/JSON files has recently been limited to members of the [[ویکی\u200cپدیا:Interface administrators|Interface administrators]] group. See [[m:Creation of separate user group for editing sitewide CSS/JS]] for more information.', '*': 'See https://fa.wikipedia.beta.wmflabs.org/w/api.php for API usage. Subscribe to the mediawiki-api-announce mailing list at &lt;https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce&gt; for notice of API deprecations and breaking changes.'}, 'servedby': 'deployment-mediawiki-09'}

but I already am a member of interface-admin group:

(using the same session from the above script)

print(session.post(url, b'action=query&meta=userinfo&uiprop=rights|groups&format=json').json())

prints:

{'batchcomplete': '', 'query': {'userinfo': {'id': 18, 'name': 'Dalba', 'groups': ['bureaucrat', 'interface-admin', 'sysop', 'uploader', '*', 'user', 'autoconfirmed'], 'rights': ['noratelimit', 'editinterface', 'editsitejson', 'edituserjson', 'extendedconfirmed', 'suppressredirect', 'deleterevision', 'deletelogentry', 'block', 'createaccount', 'delete', 'deletedhistory', 'deletedtext', 'undelete', 'move', 'move-subpages', 'move-rootuserpages', 'move-categorypages', 'patrol', 'autopatrol', 'protect', 'editprotected', 'rollback', 'upload', 'reupload', 'reupload-shared', 'autoconfirmed', 'editsemiprotected', 'ipblock-exempt', 'blockemail', 'markbotedits', 'apihighlimits', 'browsearchive', 'movefile', 'abusefilter-log', 'abusefilter-view', 'abusefilter-revert', 'autoreview', 'stablesettings', 'movestable', 'tboverride', 'skipcaptcha', 'abusefilter-log-detail', 'massmessage', 'flow-lock', 'flow-delete', 'flow-edit-post', 'review', 'validate', 'read', 'edit', 'createtalk', 'writeapi', 'viewmywatchlist', 'editmywatchlist', 'viewmyprivateinfo', 'editmyoptions', 'flow-hide', 'reupload-own', 'createpage', 'minoredit', 'editmyusercss', 'editmyuserjson', 'editmyuserjs', 'purge', 'sendemail', 'applychangetags', 'changetags']}}}

Tested both on https://fa.wikipedia.org/ and https://fa.wikipedia.beta.wmflabs.org/ where I have interface-admin rights.

Expected behavior: being able to edit/create interface files.

Event Timeline

Dalba updated the task description. (Show Details)

Are you sure your bot password have the rights granted?

Go to https://fa.wikipedia.org/wiki/ویژه:BotPasswords/Dalba and look for "Edit the MediaWiki namespace and sitewide/user JSON" to be checked

Thanks Umherirrender. Because of the strange translation I had not noticed that one. Sorry for that. I needed to have editsitejs right.
(Also fixed the translation on translatewiki.net)

BTW, I think the error message (...limited to members of the Interface administrators group..) should be changed to complain about the required user rights, not the user group.