Page MenuHomePhabricator

Upgrade of api-testing from 1.7.0 to 1.7.1 in Wikibase extension gives failure "Object prototype may only be an Object or null: undefined"
Closed, ResolvedPublic

Description

The update of api-testing on Wikibase extension has error from api-testing, that seems related to the new version.

https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Wikibase/+/1179238
https://integration.wikimedia.org/ci/job/quibble-vendor-mysql-php81-selenium/32851/console

22:07:44   1) An uncaught error was detected outside of a test:
22:07:44      TypeError: The following error originated from your test code, not from Cypress.
22:07:44 
22:07:44   > Object prototype may only be an Object or null: undefined
22:07:44 
22:07:44 When Cypress detects uncaught errors originating from your test code it will automatically fail the current test.
22:07:44 
22:07:44 Cypress could not associate this error to any specific test.
22:07:44 
22:07:44 We dynamically generated a new test to display this failure.
22:07:44       at Function.setPrototypeOf (<anonymous>)
22:07:44       at ./node_modules/supertest/lib/agent.js (webpack://wikibase/./node_modules/supertest/lib/agent.js:53:0)
22:07:44       at __webpack_require__ (webpack://wikibase/webpack/bootstrap:19:0)
22:07:44       at ./node_modules/supertest/index.js (webpack://wikibase/./node_modules/supertest/index.js:14:14)
22:07:44       at __webpack_require__ (webpack://wikibase/webpack/bootstrap:19:0)
22:07:44       at ./node_modules/api-testing/lib/actionapi.js (webpack://wikibase/./node_modules/api-testing/lib/actionapi.js:4:18)
22:07:44       at __webpack_require__ (webpack://wikibase/webpack/bootstrap:19:0)
22:07:44       at ./node_modules/api-testing/lib/action_clients.js (webpack://wikibase/./node_modules/api-testing/lib/action_clients.js:4:15)
22:07:44       at __webpack_require__ (webpack://wikibase/webpack/bootstrap:19:0)
22:07:44       at ./node_modules/api-testing/index.js (webpack://wikibase/./node_modules/api-testing/index.js:4:9)

Event Timeline

I believe that’s the same issue as supertest#867 / superagent#1840 – I don’t remember if there was already a Phabricator task for it, though it was mentioned in the commit message of the change introducing these tests. @ArthurTaylor proposed a fix upstream at superagent#1839, but there’s been no response so far.

Umherirrender renamed this task from Upgrade api-testing 1.7.0 → 1.7.1 in Wikibase extension has failure Object prototype may only be an Object or null: undefined to Upgrade of api-testing from 1.7.0 to 1.7.1 in Wikibase extension gives failure "Object prototype may only be an Object or null: undefined".Sep 22 2025, 6:39 PM
Umherirrender unsubscribed.

Still happening, e.g. on this LibUp change. After four months of no response on the upstream issue or pull request (and little other activity on the linked repo either), maybe we should reconsider the use of supertest/superagent in api-testing

(Also trying a new tag given that Core Platform Team Initiatives (API Integration Tests) is archived.)

aaron triaged this task as Low priority.Dec 17 2025, 5:47 PM
aaron moved this task from Incoming (Needs Triage) to Bugs & Chores on the MW-Interfaces-Team board.

Still happening, e.g. on this LibUp change.

Looks like WikibaseQualityConstraints will also need a manual version bump, LibUp seemingly isn’t picking up the new superagent+supertest versions automatically.

Change #1224690 had a related patch set uploaded (by Audrey Penven; author: Audrey Penven):

[mediawiki/tools/api-testing@master] Update supertest to 7.2.2

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

Change #1224690 merged by jenkins-bot:

[mediawiki/tools/api-testing@master] Update supertest to 7.2.2

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

The current version of api-testing locks supertest at "7.1.0", which I assume is why LibUp could not update it.
A patch to bump the dependency in api-testing is merged, but we'll need a new release of that before it is available.

This patch updates the version: https://gerrit.wikimedia.org/r/c/mediawiki/tools/api-testing/+/1224717
Someone with the right permissions in npm will need to do the release.

And then I think we need an update to LibUp’s config so it’ll start to push out the new version everywhere. (We’ll need to do Wikibase manually, but e.g. WikibaseQualityConstraints can hopefully be done by LibUp.)

LibUp's config was updated yesterday, so now I'm confused about a couple things:

  • Wikibase is one of the repos monitored by LibUp. Why does it need to be done manually? Is it because the last attempt to update (to api-testing, v1.7.1) failed?
  • If we expect WikibaseQualityConstraints to be done by LibUp, why hasn't it been done yet? If I'm reading it right, the logs from its run this morning do not include updating api-testing to 1.7.2.

LibUp's config was updated yesterday, so now I'm confused about a couple things:

  • Wikibase is one of the repos monitored by LibUp. Why does it need to be done manually? Is it because the last attempt to update (to api-testing, v1.7.1) failed?

LibUp insists on being able to update eslint config to automatically ignore any failing rules, and Wikibase’s non-JSON config breaks that: T391763, T372465. So LibUp generally doesn’t work for Wikibase.

  • If we expect WikibaseQualityConstraints to be done by LibUp, why hasn't it been done yet? If I'm reading it right, the logs from its run this morning do not include updating api-testing to 1.7.2.

I was also unsure about that; I think it might be because, according to its status page, api-testing 1.7.2 is still in the “canary” stage?

image.png (166×516 px, 27 KB)

(Even though the VisualEditor change has in fact been merged successfully – maybe LibUp will only refresh its information on its next daily(?) run.)

Change #1224971 had a related patch set uploaded (by Audrey Penven; author: Audrey Penven):

[mediawiki/extensions/Wikibase@master] Upgrade api-testing to 1.7.2

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

Although, looking at the change you linked in the commit message there – maybe we can try to let LibUp upgrade Wikibase after all, and it’ll work as long as it doesn’t have to touch the eslint config? (I wasn’t aware that change existed – looks like LibUp+Wikibase isn’t quite as broken as I thought.)

Should we just wait and see what LibUp does in its next run then?

Ahhh maybe not. A test failure on CI lead me to this commit in api-testing, which makes the config into a module object rather than a function.

in extensions/Wikibase/repo/domains/crud/tests/mocha/api-testing/AbuseFilterTest.js, it is assumed that this config is a function:

const config = require( 'api-testing/lib/config' )();

I see… then let’s do a manual upgrade that adjusts this code as needed, yeah. (Hopefully it’s still possible to access the config somewhere…)

Change #1224971 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] Upgrade api-testing to 1.7.2

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

In WikibaseQualityConstraints the upgrade was successful \o/

https://gerrit.wikimedia.org/r/c/mediawiki/extensions/WikibaseQualityConstraints/+/1216884

I think we can move this to verification then?