Page MenuHomePhabricator

Log response headers from MediaWiki API errors
Closed, ResolvedPublicFeature

Description

Pywikibot should log response headers when the response is an error from MediaWiki API ('error' in result).

In T272319#6756412, Tgr wrote:

Pywikibot should probably log the X-Request-Id header in the API response and include it into error reports.

Event Timeline

JJMC89 changed the subtype of this task from "Task" to "Feature Request".Jan 18 2021, 11:46 PM

Where would be a good place to do this?

By the time we check if it is an error (pywikibot/data/api.py#L1821), we don't have access to the respose object.

I think pywikibot/comms/http.py#L255-L257 is the last point with access to the response object, but it hasn't been loaded to check if it is an error.

Xqt triaged this task as Medium priority.

Change 657042 had a related patch set uploaded (by Xqt; owner: Xqt):
[pywikibot/core@master] [IMPR] Add requests.Response.headers to log during APIError

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

Change 657042 merged by jenkins-bot:
[pywikibot/core@master] [IMPR] Add requests.Response.headers to log when an API error occurs

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