Page MenuHomePhabricator

REST API /transform/ endpoint api-testing tests break in Wikibase gate-and-submit
Closed, ResolvedPublic

Description

Three Wikibase gate-and-submits (for different changes) failed with the same errors (except for the hash in the TransformSource name):

4 failing

1) /transform/ endpoint
     ETags
       /transform/ should refuse non-matching ETags in header:

    AssertionError: {"reason":"The given page ([0:TransformSource_0ZbZaRyLAW]) does not belong to page ID 383 but actually belongs to 425","key":"1337/deadbeef","errorKey":"rest-bad-stash-key","messageTranslations":{"en":"Bad stash key."},"httpCode":400,"httpReason":"Bad Request"}: expected 400 to deeply equal 412
    + expected - actual

    -400
    +412
    
    at Context.<anonymous> (tests/api-testing/REST/Transform.js:2344:11)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

2) /transform/ endpoint
     ETags
       /transform/ should refuse non-matching ETags in the body:

    AssertionError: {"reason":"The given page ([0:TransformSource_0ZbZaRyLAW]) does not belong to page ID 383 but actually belongs to 425","key":"1337/deadbeef","errorKey":"rest-bad-stash-key","messageTranslations":{"en":"Bad stash key."},"httpCode":400,"httpReason":"Bad Request"}: expected 400 to deeply equal 412
    + expected - actual

    -400
    +412
    
    at Context.<anonymous> (tests/api-testing/REST/Transform.js:2355:11)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

3) /transform/ endpoint
     stashing with If-Match header
       should fail if eTag in If-Match header is unknown:

    AssertionError: expected 400 to equal 412
    + expected - actual

    -400
    +412
    
    at Context.<anonymous> (tests/api-testing/REST/Transform.js:2395:36)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

4) /transform/ endpoint
     stashing with renderid in body
       should fail if stash key is unknown:

    AssertionError: expected 400 to equal 412
    + expected - actual

    -400
    +412
    
    at Context.<anonymous> (tests/api-testing/REST/Transform.js:2435:36)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Event Timeline

The /transform/ tests had previously failed in T320935, but these errors look different.

The build history at the moment shows some successful core builds, some successful GrowthExperiments builds, and then some failed Wikibase builds; so we don’t know yet whether this is specific to Wikibase, or whether it potentially affects all extensions but no other repo has had a new build since it broke.

Change #1037004 had a related patch set uploaded (by Lucas Werkmeister (WMDE); author: Lucas Werkmeister (WMDE)):

[mediawiki/core@master] DNM: Test CI for T366142

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

Well, this core build (for this change) succeeded, so this might be specific to Wikibase indeed… though it’s far from clear to me how.

So far, I can’t seem to reproduce this locally:

( await fetch( 'http://localhost/wiki1/rest.php/v1/transform/html/to/wikitext/', { method: 'POST', body: JSON.stringify( { html: '<p>test</p>', original: { renderid: '"1234/dummy"' } } ), headers: { 'content-type': 'application/json' } } ) ).status
// -> 412, as expected

Change #1037036 had a related patch set uploaded (by Lucas Werkmeister (WMDE); author: Lucas Werkmeister (WMDE)):

[mediawiki/extensions/GrowthExperiments@master] DNM: Test CI for T366142

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

Change #1037036 abandoned by Lucas Werkmeister (WMDE):

[mediawiki/extensions/GrowthExperiments@master] DNM: Test CI for T366142

Reason:

apitests worked here

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

I can reproduce this locally in the quibble container. It seems that the Wikibase api tests put the system in a state where the mediawiki tests fail.

If I run:

npx mocha -- --recursive tests/api-testing/

from /workspace/src, it passes fine. If I first run:

npx npm-run-all -p api-testing:*

from /workspace/src/extensions/Wikibase, the tests fail. I'll try and dig a bit into why this is.

Change #1037076 had a related patch set uploaded (by Lucas Werkmeister (WMDE); author: Lucas Werkmeister (WMDE)):

[mediawiki/extensions/Wikibase@master] DNM: Avoid site without language

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

Change #1037004 abandoned by Lucas Werkmeister (WMDE):

[mediawiki/core@master] DNM: Test CI for T366142

Reason:

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

Change #1037076 abandoned by Lucas Werkmeister (WMDE):

[mediawiki/extensions/Wikibase@master] DNM: Avoid site without language

Reason:

didn’t help; the stack trace was apparently not the cause of the problem

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

Change #1037016 had a related patch set uploaded (by Silvan Heintze; author: Silvan Heintze):

[mediawiki/core@master] Revert "[HtmlInputTransformHelper] Use ParserOutputAccess"

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

{"reason":"The given page ([0:TransformSource_0ZbZaRyLAW]) does not belong to page ID 383 but actually belongs to 425",

Is this legit? Is the root cause here that we're reusing a page ID and/or a title?

I think I remember seeing another issue like this, where ::getNonexistingTestPage() would return the same page ID for two different titles in two different runs, which confused things when the stash (or whatever) wasn't reset between tests.

Change #1037115 had a related patch set uploaded (by Ollie Shotton; author: Ollie Shotton):

[mediawiki/extensions/WikibaseLexeme@master] DNM: Test CI for T366142

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

Change #1037115 abandoned by Ollie Shotton:

[mediawiki/extensions/WikibaseLexeme@master] DNM: Test CI for T366142

Reason:

, CI works here

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

Change #1037377 had a related patch set uploaded (by Jakob; author: Jakob):

[mediawiki/core@master] Increase ETag number in transform tests

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

Change #1037016 abandoned by Silvan Heintze:

[mediawiki/core@master] Revert "[HtmlInputTransformHelper] Use ParserOutputAccess"

Reason:

no revert needed, since this can be fixed via I5521b7652faca9821fa08a9987a9452a4c555203

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

Change #1037377 merged by jenkins-bot:

[mediawiki/core@master] api-testing: Increase ETag number in transform tests

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

Change #1041144 had a related patch set uploaded (by Lucas Werkmeister (WMDE); author: Lucas Werkmeister (WMDE)):

[mediawiki/core@master] api-testing: Further increase ETag number in transform tests

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

Change #1041144 merged by jenkins-bot:

[mediawiki/core@master] api-testing: Further increase ETag number in transform tests

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