Page MenuHomePhabricator

Cannot access Wikitext transformation REST API passing titles of subpages of subpages
Closed, InvalidPublicBUG REPORT

Description

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

  • Run
curl -X POST -H "Content-Type: application/json" --data '{ "wikitext": "== Hello Jupiter ==[[Link|text]]<table><table>" }' 'https://www.mediawiki.org/w/rest.php/v1/transform/wikitext/to/lint/Project:International_Help_Pages/fr/Mod%C3%A8le_Cadre'

What happens?:
This error is returned:
{"errorKey":"rest-no-match","messageTranslations":{"en":"The requested relative path (/v1/transform/wikitext/to/lint/Project:International_Help_Pages/fr/Mod%C3%A8le_Cadre) did not match any known handler"},"httpCode":404,"httpReason":"Not Found"}

The same error would have been thrown if we had tried to access the Wikitext to HTML transformation endpoint. But the error goes away if I remove the last forward-slash and make the URL have only two forward-slashes (and thus have the endpoint treat it as a subpage of a page that's not a subpage rather than a subpage of a subpage).

What should have happened instead?:

It should have returned the lint errors for the provided Wikitext.

Event Timeline

I don't know if this should be necessary but the ending slash might be treated as indicating a parameter afterwards, or some such. At any rate, if I run

curl -X POST -H "Content-Type: application/json" --data '{ "wikitext": "== Hello Jupiter ==[[Link|text]]<table><table>" }' 'https://www.mediawiki.org/w/rest.php/v1/transform/wikitext/to/lint/Project:International_Help_Pages%2Ffr%2FMod%C3%A8le_Cadre'

then I get the appropriate output

[{"type":"missing-end-tag","dsr":[39,46,7,0],"templateInfo":null,"params":{"name":"table","inTable":true}},{"type":"deletable-table-tag","dsr":[39,46,0,0],"templateInfo":null,"params":{"name":"table"}}]

which is what you were expecting. I would urlencode slashes in the title as a general rule, to avoid this sort of thing.

... I would urlencode slashes in the title as a general rule, to avoid this sort of thing.

Yes, that’s what I have been doing since discovering this issue but I would like to avoid that because I am worried about how this could affect the Wikitext output which could rely on the page title (by way of things like magic words).

... I would urlencode slashes in the title as a general rule, to avoid this sort of thing.

Yes, that’s what I have been doing since discovering this issue but I would like to avoid that because I am worried about how this could affect the Wikitext output which could rely on the page title (by way of things like magic words).

I don't think that should be a problem; arguments like the title should be url-decoded before being passed to anything that would use them, including magic word substitution. If you run across an instance where this is not happening properly, please do file a phabricator task about it, because that's a bug.

I don't think that should be a problem; arguments like the title should be url-decoded before being passed to anything that would use them, including magic word substitution. If you run across an instance where this is not happening properly, please do file a phabricator task about it, because that's a bug.

Thanks, I just tested this and it seems to be working fine. (I was not able to test whether it would have worked for the example in this task because of T440827 but it worked when I tried URL-encoding @ in the root page name.)

BPirkle subscribed.

It sounds like url encoding the input parameter addressed this issue. If I'm misunderstanding, please reopen. (A status of Invalid here doesn't mean anything in the report was factually incorrect, just that it turned out to not be a bug after all)