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
Open, Needs TriagePublic

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.