Page MenuHomePhabricator

Error: exception of type Error: Cannot unpack array with string keys
Closed, ResolvedPublic

Description

This is showing up on apitesting test jobs for all GrowthExperiments patches:

{
  "message": "Error: exception of type Error: Cannot unpack array with string keys",
  "exception": {
    "id": "0cae2c086252421d907e9a53",
    "type": "Error",
    "file": "/workspace/src/includes/GlobalFunctions.php",
    "line": 1179,
    "message": "Cannot unpack array with string keys",
    "code": 0,
    "url": "/rest.php/growthexperiments/v0/quickstarttips/minerva/visualeditor/copyedit/en",
    "caught_by": "other",
    "backtrace": [
      {
        "file": "/workspace/src/includes/context/DerivativeContext.php",
        "line": 288,
        "function": "wfMessage",
        "args": [
          "array"
        ]
      },
      {
        "file": "/workspace/src/extensions/GrowthExperiments/includes/HelpPanel/Tips/TipNodeRenderer.php",
        "line": 207,
        "function": "msg",
        "class": "DerivativeContext",
        "type": "->",
        "args": [
          "array"
        ]
      },
      {
        "function": "GrowthExperiments\\HelpPanel\\Tips\\{closure}",
        "class": "GrowthExperiments\\HelpPanel\\Tips\\TipNodeRenderer",
        "type": "->",
        "args": [
          "array"
        ]
      },
      {
        "file": "/workspace/src/extensions/GrowthExperiments/includes/HelpPanel/Tips/TipNodeRenderer.php",
        "line": 226,
        "function": "array_map",
        "args": [
          "Closure",
          "array"
        ]
      },
      {
        "file": "/workspace/src/extensions/GrowthExperiments/includes/HelpPanel/Tips/TipNodeRenderer.php",
        "line": 110,
        "function": "getMessageParameters",
        "class": "GrowthExperiments\\HelpPanel\\Tips\\TipNodeRenderer",
        "type": "->",
        "args": [
          "GrowthExperiments\\HelpPanel\\Tips\\TipNode",
          "string"
        ]
      },
      {
        "file": "/workspace/src/extensions/GrowthExperiments/includes/HelpPanel/Tips/TipNodeRenderer.php",
        "line": 69,
        "function": "mainAndTextRender",
        "class": "GrowthExperiments\\HelpPanel\\Tips\\TipNodeRenderer",
        "type": "->",
        "args": [
          "GrowthExperiments\\HelpPanel\\Tips\\TipNode",
          "string"
        ]
      },
      {
        "file": "/workspace/src/extensions/GrowthExperiments/includes/HelpPanel/Tips/TipNodeRenderer.php",
        "line": 53,
        "function": "buildHtml",
        "class": "GrowthExperiments\\HelpPanel\\Tips\\TipNodeRenderer",
        "type": "->",
        "args": [
          "GrowthExperiments\\HelpPanel\\Tips\\TipNode",
          "string",
          "string"
        ]
      },
      {
        "function": "GrowthExperiments\\HelpPanel\\Tips\\{closure}",
        "class": "GrowthExperiments\\HelpPanel\\Tips\\TipNodeRenderer",
        "type": "->",
        "args": [
          "GrowthExperiments\\HelpPanel\\Tips\\TipNode"
        ]
      },
      {
        "file": "/workspace/src/extensions/GrowthExperiments/includes/HelpPanel/Tips/TipNodeRenderer.php",
        "line": 54,
        "function": "array_map",
        "args": [
          "Closure",
          "array"
        ]
      },
      {
        "file": "/workspace/src/extensions/GrowthExperiments/includes/HelpPanel/Tips/TipsAssembler.php",
        "line": 71,
        "function": "render",
        "class": "GrowthExperiments\\HelpPanel\\Tips\\TipNodeRenderer",
        "type": "->",
        "args": [
          "array",
          "string",
          "string"
        ]
      },
      {
        "function": "GrowthExperiments\\HelpPanel\\Tips\\{closure}",
        "class": "GrowthExperiments\\HelpPanel\\Tips\\TipsAssembler",
        "type": "->",
        "args": [
          "array"
        ]
      },
      {
        "file": "/workspace/src/extensions/GrowthExperiments/includes/HelpPanel/Tips/TipsAssembler.php",
        "line": 72,
        "function": "array_map",
        "args": [
          "Closure",
          "array"
        ]
      },
      {
        "file": "/workspace/src/extensions/GrowthExperiments/includes/Rest/Handler/TipsHandler.php",
        "line": 70,
        "function": "getTips",
        "class": "GrowthExperiments\\HelpPanel\\Tips\\TipsAssembler",
        "type": "->",
        "args": [
          "string",
          "string",
          "array",
          "string",
          "string"
        ]
      },
      {
        "file": "/workspace/src/includes/Rest/SimpleHandler.php",
        "line": 38,
        "function": "run",
        "class": "GrowthExperiments\\Rest\\Handler\\TipsHandler",
        "type": "->",
        "args": [
          "string",
          "string",
          "string",
          "string"
        ]
      },
      {
        "file": "/workspace/src/includes/Rest/Router.php",
        "line": 414,
        "function": "execute",
        "class": "MediaWiki\\Rest\\SimpleHandler",
        "type": "->",
        "args": []
      },
      {
        "file": "/workspace/src/includes/Rest/Router.php",
        "line": 338,
        "function": "executeHandler",
        "class": "MediaWiki\\Rest\\Router",
        "type": "->",
        "args": [
          "GrowthExperiments\\Rest\\Handler\\TipsHandler"
        ]
      },
      {
        "file": "/workspace/src/includes/Rest/EntryPoint.php",
        "line": 167,
        "function": "execute",
        "class": "MediaWiki\\Rest\\Router",
        "type": "->",
        "args": [
          "MediaWiki\\Rest\\RequestFromGlobals"
        ]
      },
      {
        "file": "/workspace/src/includes/Rest/EntryPoint.php",
        "line": 132,
        "function": "execute",
        "class": "MediaWiki\\Rest\\EntryPoint",
        "type": "->",
        "args": []
      },
      {
        "file": "/workspace/src/rest.php",
        "line": 31,
        "function": "main",
        "class": "MediaWiki\\Rest\\EntryPoint",
        "type": "::",
        "args": []
      }
    ]
  },
  "httpCode": 500,
  "httpReason": "Internal Server Error"
}

It's not from anything we've changed.

Event Timeline

kostajh triaged this task as Unbreak Now! priority.Mar 8 2022, 10:44 AM
kostajh created this task.
Restricted Application added subscribers: Masumrezarock100, Aklapper. · View Herald Transcript

Unable to reproduce it locally so far.

Looks like you're passing an associative array to msg() somewhere instead of a list, which (surprisingly to me) seems to have worked correctly before, although nothing in the documentation suggested that it would. I can make it work again if it would be tedious to fix in GrowthExperiments.

(This is caused by https://gerrit.wikimedia.org/r/c/mediawiki/core/+/768837, but this change wasn't the focus of that patch)

(This is caused by https://gerrit.wikimedia.org/r/c/mediawiki/core/+/768837, but this change wasn't the focus of that patch)

I'm confused as to why I can't reproduce this locally with that core patch, though.

If you're running a more recent version of PHP, then unpacking an array with string keys is no longer impossible! :D

(This is caused by https://gerrit.wikimedia.org/r/c/mediawiki/core/+/768837, but this change wasn't the focus of that patch)

I'm confused as to why I can't reproduce this locally with that core patch, though.

Oh, sorry. Confusingly, the issue only occurs for some task types, but not all. I can reproduce with http://localhost:8080/w/rest.php/growthexperiments/v0/quickstarttips/minerva/visualeditor/copyedit/en . Let me see if I can fix this easily in GrowthExperiments.

I think this line:

$parameterMessageKey = $nodeConfig['variant'][$skinName] ?? $nodeConfig['data'];

should be:

$parameterMessageKey = $nodeConfig['variant'][$skinName]['data'] ?? $nodeConfig['data'];

The $nodeConfig seems to be coming from TipTree::getEditMessageTipConfigData().

Change 769030 had a related patch set uploaded (by Kosta Harlan; author: Kosta Harlan):

[mediawiki/extensions/GrowthExperiments@master] TipNodeRenderer: Ensure array of messages doesn't have string keys

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

I think this line:

$parameterMessageKey = $nodeConfig['variant'][$skinName] ?? $nodeConfig['data'];

should be:

$parameterMessageKey = $nodeConfig['variant'][$skinName]['data'] ?? $nodeConfig['data'];

The $nodeConfig seems to be coming from TipTree::getEditMessageTipConfigData().

Indeed. Thanks for looking.

Change 769030 merged by jenkins-bot:

[mediawiki/extensions/GrowthExperiments@master] TipNodeRenderer: Ensure array of messages doesn't have string keys

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