Page MenuHomePhabricator

mwapi_responses: query field may not exist
Closed, ResolvedPublic

Description

Test this API call:
https://en.wikipedia.org/w/api.php?action=query&format=json&formatversion=2&generator=categorymembers&gcmtitle=Category:February&gcmnamespace=1

Notice that there is no "query" field in the response. This means that the struct automatically generated cannot just assume the query field exists.

While it is easy to wrap that in an Option, I believe such a change would break every existing code so this is not an easy task.

Details

TitleReferenceAuthorSource BranchDest Branch
Handle the query field not existingrepos/mwbot-rs/mwbot!50legoktmno-query-bodymain
Customize query in GitLab

Event Timeline

Wow, I had no idea this was even possible. Maybe we use Default to add an empty query field?

Can you do the same with other API modules? Wonder if we should file a bug against MediaWiki-Action-API to make this behavior more consistent/predictable...

My guess is that this is related with miser mode. Similarly this API call also has no query field: https://en.wikipedia.org/w/api.php?action=query&format=json&generator=exturlusage&formatversion=2&geuquery=google.com&geunamespace=711

I would like to see both happening. Default could be implemented, and a bug could be filed.

@MilkyDefer want to try out the above patch? I think it should cover it.

Awesome, just released mwapi_responses 0.3.4 with the fix :)