Page MenuHomePhabricator

Flaky Cypress test: wbui2025 time datatypes: mobile view - time datatype: allows adding time statement to empty item, displays statement and supports full editing workflow
Closed, ResolvedPublic

Description

Seen in this build (kept forever) for this unrelated Translate change:

  1) wbui2025 time datatypes
       mobile view - time datatype
         allows adding time statement to empty item, displays statement and supports full editing workflow:
     Error: The following error originated from your application code, not from Cypress. It was caused by an unhandled promise rejection.

  > missingparam

When Cypress detects uncaught errors originating from your application it will automatically fail the current test.

This behavior is configurable, and you can choose to turn this off by listening to the `uncaught:exception` event.

https://on.cypress.io/uncaught-exception-from-application
      at makeErrFromObj (http://127.0.0.1:9413/__cypress/runner/cypress_runner.js:77431:12)
      at errorFromProjectRejectionEvent (http://127.0.0.1:9413/__cypress/runner/cypress_runner.js:77756:10)
      at Object.errorFromUncaughtEvent (http://127.0.0.1:9413/__cypress/runner/cypress_runner.js:77761:65)
      at <unknown> (http://127.0.0.1:9413/__cypress/runner/cypress_runner.js:141894:66)

screenshot:

image.png (720×1 px, 179 KB)

Event Timeline

I have no idea how a missingparam error could be flaky, surely we’re always calling the API with a consistent set of parameters…

The screenshot of that build looks slightly different than in the task description:

image.png (720×1 px, 222 KB)

But I just noticed something: the API request seen in both screenshots really is invalid!

{
  "errors": [
    {
      "code": "missingparam",
      "module": "wbformatvalue",
      "*": "The \"datavalue\" parameter must be set."
    }
  ],
  "servedby": "mw-api-ext.eqiad.main-66467fdf7d-t9fn9",
  "*": "See https://www.wikidata.org/w/api.php for API usage. Subscribe to the mediawiki-api-announce mailing list at &lt;https://lists.wikimedia.org/postorius/lists/mediawiki-api-announce.lists.wikimedia.org/&gt; for notice of API deprecations and breaking changes."
}

So we’re somehow sending a request with no datavalue at all to action=wbformatvalue.

Aha, TIL JSON.stringify( undefined ) returns undefined. So when we have

renderSnakValue()
	const params = {
		action: 'wbformatvalue',
		generate: generate,
		datavalue: JSON.stringify( dataValue )
	};

the datavalue is undefined and mw.Api strips it out. So we just™ need to make sure not to pass undefined values into the renderSnak*() functions.

https://gerrit.wikimedia.org/r/c/mediawiki/core/+/1241256

The console logs in the Jenkins web UI of these jobs are very confusing, I can only see the failing tests from the plain text view. Two of the above are the same as the description, another one as below:

  Running:  addQualifier.cy.ts                                                             (2 of 12)


  wbui2025 add qualifiers
    mobile view
      ✓ is possible to add and edit a qualifier (14425ms)
    mobile view (wbui2025) - tabular-data qualifier
      1) can add a tabular-data qualifier with lookup
    mobile view (wbui2025) - geo-shape qualifier
      ✓ can add a geo-shape qualifier with lookup (2745ms)
      ✓ shows dropdown menu when typing in geo-shape qualifier lookup (2359ms)


  3 passing (41s)
  1 failing

  1) wbui2025 add qualifiers
       mobile view (wbui2025) - tabular-data qualifier
         can add a tabular-data qualifier with lookup:
     AssertionError: Timed out retrying after 20000ms: Expected to find element: `[data-v-app] .wikibase-wbui2025-edit-link`, but never found it.
      at __webpack_modules__../cypress/support/pageObjects/ItemViewPage.ts.ItemViewPage.editLinks (webpack://wikibase/./cypress/support/pageObjects/ItemViewPage.ts:53:12)
      at Context.eval (webpack://wikibase/./cypress/e2e/wbui2025/addQualifier.cy.ts:205:16)


The screenshot of that build looks slightly different than in the task description:

image.png (720×1 px, 222 KB)

But I just noticed something: the API request seen in both screenshots really is invalid!

Also note that there is an invalid API call with value= (empty string) to action=wbparsevalue

Also note that there is an invalid API call with value= (empty string) to action=wbparsevalue

Good catch, thanks – that must be where the undefined value to parse comes from, then. (But wbparsevalue doesn’t complain about it because its values= parameter takes a list, unlike wbformatvalue, and it’s okay for the list to be empty. So we only notice the error one API call later.)

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

[mediawiki/extensions/Wikibase@master] Make sure parseValue() doesn’t return undefined

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

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

[mediawiki/extensions/Wikibase@master] Don’t make an API call to parse the empty string

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

Change #1269008 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] Make sure parseValue() doesn’t return undefined

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

Change #1269009 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] Don’t make an API call to parse the empty string

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

The issue seems to be fixed as it didn't occur again, I will mark it as resolved.
(If for some reason, it appeared again, we can reopen this task).
Thank you!