Page MenuHomePhabricator

Add better error handling for API usage
Closed, ResolvedPublic

Description

When trying to upgrade Wikibase I sometimes get errors like this:

00:06:28.377 [chrome-headless-shell 120.0.6099.224 linux #0-6] Cannot read properties of undefined (reading 'id')
00:06:28.377 [chrome-headless-shell 120.0.6099.224 linux #0-6] TypeError: Cannot read properties of undefined (reading 'id')
00:06:28.377 [chrome-headless-shell 120.0.6099.224 linux #0-6]     at WikibaseApi.createItem (file:///workspace/src/extensions/Wikibase/node_modules/wdio-wikibase/wikibase.api.js:70:26)

The problem is that when there's an error from the MW API, we just parse the JSON and return what we have. Before we rejected the promise with an error message. Lets make sure core do that (and log the actual error).

Details

Event Timeline

Change #1268365 had a related patch set uploaded (by Phedenskog; author: Phedenskog):

[mediawiki/core@master] selenium: Catch MediaWiki API errors and log

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

Change #1268365 merged by jenkins-bot:

[mediawiki/core@master] selenium: Catch MediaWiki API errors and log

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

Peter moved this task from In Review to Done on the Test Platform (Črnomerec 24) board.

This is an example of the fix that I could see in Wikibase (much better)

Screenshot 2026-04-08 at 13.31.47.png (2,288×388 px, 184 KB)