Page MenuHomePhabricator

Tune how mwbot handles JSON errors
Closed, DeclinedPublicBUG REPORT

Description

As reported in T372068#11075998 we sometimes gets errors like:

Error: invalidjson: No valid JSON response
at /src/node_modules/mwbot/src/index.js:254:31
at tryCatcher (/src/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/src/node_modules/bluebird/js/release/promise.js:547:31)
at Promise._settlePromise (/src/node_modules/bluebird/js/release/promise.js:604:18)
at Promise._settlePromise0 (/src/node_modules/bluebird/js/release/promise.js:649:10)
at Promise._settlePromises (/src/node_modules/bluebird/js/release/promise.js:729:18)
at _drainQueueStep (/src/node_modules/bluebird/js/release/async.js:93:12)
at _drainQueue (/src/node_modules/bluebird/js/release/async.js:86:9)
at Async._drainQueues (/src/node_modules/bluebird/js/release/async.js:102:5)
at Async.drainQueues [as _onImmediate] (/src/node_modules/bluebird/js/release/async.js:15:14)
at process.processImmediate (node:internal/timers:483:21)

We get that it's invalid JSON but can't see/understand what's going on. We should make PR for mwbot where it instead of hardcode the error reason also includes information from the page. For example status code (if it's not a 200), and some part of the response. That way we will be able to see/understand what's going on in the logs.

Expected Behavior: When we get an JSON error from mwbot in the logs we should be able to understand what's wrong
Actual Behavior: The only error we get is No valid JSON response
Steps to reproduce: Check T372068 or you could probably just point mwbot to a page that returns HTML/error page and you will get that error

Notes:

  • MWBot is abandoned, so our PR won't be reviewed and merged

Event Timeline

Change #1177594 had a related patch set uploaded (by Vaughn Walters; author: Vaughn Walters):

[mediawiki/extensions/CampaignEvents@master] selenium: Adding more error handling for mwbot

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

Change #1177594 merged by jenkins-bot:

[mediawiki/extensions/CampaignEvents@master] selenium: Adding more error handling for mwbot

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

For the specific instance of selenium daily jobs, the cause is an HTTP redirect to the new beta domain: T393428#11077617. I'll make a patch for that task instead. For this task, I think the next steps would be to upstream the additional logging to wdio-mediawiki and mwbot.

We switched out mwbot in 6.0.0 so we don't need to do this.