Page MenuHomePhabricator

wrong url redirection for wikimediafoundation.org api
Open, Needs TriagePublicBUG REPORT

Description

https://wikimediafoundation.org/w/api.php is redirected to https://foundation.wikimedia.org/w/api.php. But when redirecting the url the "|" delimiters of the query are lost.

Current behaviour
Following https://wikimediafoundation.org/w/api.php?action=query&meta=siteinfo&siprop=general|namespaces|namespacealiases|statistics

will be forwardet to the url
https://foundation.wikimedia.org/w/api.php?action=query&meta=siteinfo&siprop=generalnamespacesnamespacealiasesstatistics and the error message is:

{
    "batchcomplete": "",
    "warnings": {
        "siteinfo": {
            "*": "Unrecognized value for parameter \"siprop\": generalnamespacesnamespacealiasesstatistics"
        }
    }
}

Expected behaviour:
Redirection should be either
https://foundation.wikimedia.org/w/api.php?action=query&meta=siteinfo&siprop=general|namespaces|namespacealiases|statistics
or even better wikimediafoundation should have its own api path like https://wikimediafoundation.org/w/api.php?

Event Timeline

Xqt changed the subtype of this task from "Task" to "Bug Report".Jan 29 2024, 5:22 AM
Varnent subscribed.

The URL redirect for wikimediafoundation.org is already set with a redirect wildcard - so nothing more can be done on that front. It is not a MediaWiki based site - so adding an API setup would not resolve this issue (although the site does have its own API system).

I think the solution is to fix the incorrect origin link - will look into that as a part of T331680.

Change 994394 had a related patch set uploaded (by Varnent; author: Varnent):

[pywikibot/core@master] Modify family file for Foundation Governance Wiki to see if it addresses a related bug.

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

@Xqt: Do you have any idea where it is getting that URL from? I am not having any luck tracking it down - but changing interwiki to same setup as MediaWiki and others perhaps will help?

Change 994398 had a related patch set uploaded (by Varnent; author: Varnent):

[integration/visualdiff@master] Update baseURL for Foundation Governance Wiki entry.

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

@Varnent: I'll try to figure out some points...

... wikimediafoundation.org ... not a MediaWiki based site

This is good to know. I could add this point to site_detect tests.

Do you have any idea where it is getting that URL from

Reading the expanded text of the Main Page on en-wiki I found this problematic Link: foundationsite:our-work/wikimedia-projects/

import pywikibot
site = pywikibot.Site('wikipedia:en')
main = site.siteinfo['mainpage']
page = pywikibot.Page(site, main)
text = page.expand_text()
text = pywikibot.textlib.removeDisabledParts(text)
links = [match['title'] for match in pywikibot.link_regex.finditer(text)]

links is a list of link titles on Main Page. Try to create a pywikibot.Link with it:
title = 'foundationsite:our-work/wikimedia-projects/'
link = pywikibot.Link(title)
Ask for the site:

print(repr(link.site))
APISite("wikimediafoundation", "wikimediafoundation")

Looks like a valid API site was found and it looks like a MediaWiki. The site was created by Autofamily constructor and needs an url. Where does is comes from? Link.parse_site found it. It uses interwikimap API. Please follow that link and you will find the following entry for foundationsite:

{
                "prefix": "foundationsite",
                "local": "",
                "url": "https://wikimediafoundation.org/$1"
},

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

[pywikibot/core@master] [tests] test that https://wikimediafoundation.org/$1 is not a WikiHTMLPageParser

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

Change 994398 merged by jenkins-bot:

[integration/visualdiff@master] Update baseURL for Foundation Governance Wiki entry.

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

@Xqt - I see. Given it is not a MediaWiki site - is there much we can do about that? Out of curiosity - how does it handle things like interwiki links to Phabricator or other non-MediaWiki sites?

Change 994748 merged by jenkins-bot:

[pywikibot/core@master] [tests] test that https://wikimediafoundation.org/$1 is not a wiki

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

how does it handle things like interwiki links to Phabricator or other non-MediaWiki sites?

There is a SiteDefinitionError because there is no API found for such sites. This is handled graceful somehow:

import pywikibot
link = pywikibot.Link('phab:T356013')
link
pywikibot.exceptions.SiteDefinitionError: Invalid AutoFamily('phabricator.wikimedia.org')

But for foundationsite a valid api is found.