Page MenuHomePhabricator

Improve logging of MW API exceptions in RESTBase
Closed, InvalidPublic

Description

MediaWiki exception logs look like this in RESTBase; the message will be something like [WqHN@ApAIDMAACBa2EUAAACF] Exception caught: Deleted row returned in non-changes mode. The random-looking string at the beginning is a unique token generated by MediaWiki for finding things in the log; it's good that it gets recorded in some way but it's bad that it's in the message as that breaks grouping by message (for trending errors etc). The error code will just contain the MediaWiki exception class, so grouping by that is not accurate enough. The unique ID should be its own log record field and not part of the message.

RESTBase could just parse it out from the message, or use errorformat=raw in which case the error response will be something like

"errors": [
    {
        "code": "internal_api_error_LogicException",
        "key": "apierror-exceptioncaught",
        "params": [
            "61ff22d2a7e9df3f52504b06",
            "Deleted row returned in non-changes mode"
        ]
    }
]

with the first parameter being the exception ID and the second the message. That would change the error response format for non-exception errors as well, though, so maybe more effort to implement.

Event Timeline

@Tgr the link you provided doesn't work and I can't find instances of logs that look like the one you're talking about in restbase logs. Can you show one again please?

Seems like this changed since or I was confused. This is a more recent example and the exception ID (and message) is not included in the log message:

@timestamp              2018-05-01T21:08:57
@version                1
_id                     AWMdiXPgCNV3ID_aQFqD
_type                   restbase
host                    restbase1017
level                   ERROR
levelPath               error/request
message                 MW API call error internal_api_error_LogicException
normalized_message      MW API call error internal_api_error_LogicException
request_id              dc82925f-4d83-11e8-8b69-a2c9da5c6538
res_body_description    [WujXaQpAEDYAAJYCRZ4AAAAD] Exception caught: deleteListEntry failed for unknown reason
res_body_title          internal_api_error_LogicException
res_body_type           server_error
...