Page MenuHomePhabricator

Attribution API: Redirects move to the wrong REST url/endpoint
Closed, ResolvedPublic2 Estimated Story PointsBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

  • Fetch https://en.wikipedia.org/w/rest.php/attribution/v0-beta/pages/Einstein/signals?redirect=true

What happens?:

  • The endpoint redirects to https://en.wikipedia.org/w/rest.php/pages/Albert_Einstein/signals?redirect=no
    • Note the missing /attribution/v0-beta prefix for the module

What should have happened instead?:

We should have had a true redirect from Einstein to Albert_Einstein, and the new link should have been: https://en.wikipedia.org/w/rest.php/attribution/v0-beta/pages/Albert_Einstein/signals?redirect=true

I am not sure if this is happening as part of the REST Module issue (is it ignoring the module prefix?) or a missing definition/wrong way to do it in-code. The code to handle redirects was copied/utilized from other REST handlers, but those handlers are in core, where the module wasn't defined, so it *may* have obscured this bug.

... or it might have been a missing extra definition in the specific Attribution Handler.

Event Timeline

Quick triage, posted to slack as well:

Reproduced locally as http://localhost:8087/w/rest.php/attribution/v0-beta/pages/FooRedirect/signals?redirect=true

Fixed locally by changing line 66 of AttributionRestHandler to:

'/attribution/v0-beta' . $this->getPath(),

That may not be the answer we really want, but maybe it at least points towards it

Slightly less bad would be:

'/' . $this->getModule()->getPathPrefix() . $this->getPath(),

Now I'm wondering if redirects from core handlers all work properly in all situations. As just one example, PageHtmlHandler implements getRedirectHelper and is exposed in both a flat route (which presumably works fine) and the content.v1 module (which is only enabled on a few dev/test wikis, but might not work so fine).

We should create a followup task for improving this at the framework level this is more convenient in the future, and we lead developers into doing things the right way instead of the wrong way.

BPirkle set the point value for this task to 2.Mar 19 2026, 3:21 PM

Change #1260136 had a related patch set uploaded (by Aghirelli; author: Aghirelli):

[mediawiki/extensions/WikimediaCustomizations@master] Rest: Fix Attribution API redirect URL missing module prefix

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

Change #1260136 merged by jenkins-bot:

[mediawiki/extensions/WikimediaCustomizations@master] Rest: Fix Attribution API redirect URL missing module prefix

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

HCoplin-WMF subscribed.

Marking as resolved to close MWI-Sprint-30 (2026-03-24 to 2026-04-07)