Page MenuHomePhabricator

function-orchestrator: Cannot destructure property 'argumentName' of 'this.argumentDeclarations_.get(...)' as it is undefined
Closed, ResolvedPublic

Description

Log error observed in the function-orchestrator service while rendering abstract content.

Error: Cannot destructure property 'argumentName' of 'this.argumentDeclarations_.get(...)' as it is undefined

Request ID: 6a68d94c-76a2-477a-bb18-88ffb644ce3c

Context: Abstract content rendering for Q104587954 with language Bangla / Z1011. Note: this appeared to work on production at time of reporting — may be intermittent.

Logstash: https://logstash.wikimedia.org/app/dashboards#/view/1ed06310-decd-11ef-859d-f36bcd343d41?_g=(filters:!(),refreshInterval:(pause:!t,value:0),time:(from:now-1d,to:now))&_a=(filters:!(('$state':(store:appState),meta:(key:orchestrator.namespace,params:(query:wikifunctions)),query:(match_phrase:(orchestrator.namespace:wikifunctions))),('$state':(store:appState),meta:(key:labels.deployment,params:(query:function-orchestrator)),query:(match_phrase:(labels.deployment:function-orchestrator))),('$state':(store:appState),meta:(key:http.request.id,params:(query:'6a68d94c-76a2-477a-bb18-88ffb644ce3c')),query:(match_phrase:(http.request.id:'6a68d94c-76a2-477a-bb18-88ffb644ce3c')))),title:'wikifunctions%20backend',viewMode:view)

Function call that triggered the error:

json
{
  "Z1K1": "Z7",
  "Z7K1": "Z21583",
  "Z21583K1": {
    "Z1K1": "Z7",
    "Z7K1": "Z29591",
    "Z29591K1": {"Z1K1": "Z6091", "Z6091K1": "Q104587954"},
    "Z29591K2": {"Z1K1": "Z6091", "Z6091K1": "Q30081"},
    "Z29591K3": {"Z1K1": "Z6091", "Z6091K1": "Q35127"},
    "Z29591K4": "Z1011"
  },
  "Z21583K2": "Z1011"
}

Event Timeline

Returned error:

function-orchestrator-1  | {"@timestamp":"2026-04-21T16:47:05.577Z","ecs.version":"8.10.0","http":{"request":{"id":"ba426b20-3da1-11f1-8a1a-bd0d24f3070d"}},"log.level":"error","message":"Orchestration failed with unidentified error: TypeError: Cannot destructure property 'argumentName' of 'this.argumentDeclarations_.get(...)' as it is undefined..","service":{"name":"function-orchestrator"},"span.id":"21d90ea85da0c6ef","trace.id":"2b51cfc726e2835271da42f89f910591","userRequest":"{\"Z1K1\":\"Z7\",\"Z7K1\":\"Z21583\",\"Z21583K1\":{\"Z1K1\":\"Z7\",\"Z7K1\":\"Z29591\",\"Z29591K1\":{\"Z1K1\":\"Z6091\",\"Z6091K1\":\"Q104587954\"},\"Z29591K2\":{\"Z1K1\":\"Z6091\",\"Z6091K1\":\"Q30081\"},\"Z29591K3\":{\"Z1K1\":\"Z6091\",\"Z6091K1\":\"Q35127\"},\"Z29591K4\":\"Z1011\"},\"Z21583K2\":\"Z1011\"}"}

I console logged the bareName and argumentDeclarations_ where it was undefined and got:

K4 is undefined.
K4 is the Natural Language (4th arg) being send to the function describing entity with adjective / class with Implementation 'send to right language' .
Which means that Argument Reference is not coming through.

function-orchestrator-1  |  >>>>>>bareName K4
function-orchestrator-1  | >>>>>>this.argumentDeclarations Map(3) {
function-orchestrator-1  |   'K1' => {
function-orchestrator-1  |     argumentName: 'Z33267K1',
function-orchestrator-1  |     argumentType: WFReference {
function-orchestrator-1  |       wfConfig_: [Object],
function-orchestrator-1  |       isValidated_: false,
function-orchestrator-1  |       ZID_: 'Z6091'
function-orchestrator-1  |     }
function-orchestrator-1  |   },
function-orchestrator-1  |   'K2' => {
function-orchestrator-1  |     argumentName: 'Z33267K2',
function-orchestrator-1  |     argumentType: WFReference {
function-orchestrator-1  |       wfConfig_: [Object],
function-orchestrator-1  |       isValidated_: false,
function-orchestrator-1  |       ZID_: 'Z6091'
function-orchestrator-1  |     }
function-orchestrator-1  |   },
function-orchestrator-1  |   'K3' => {
function-orchestrator-1  |     argumentName: 'Z33267K3',
function-orchestrator-1  |     argumentType: WFReference {
function-orchestrator-1  |       wfConfig_: [Object],
function-orchestrator-1  |       isValidated_: false,
function-orchestrator-1  |       ZID_: 'Z6091'
function-orchestrator-1  |     }
function-orchestrator-1  |   }
function-orchestrator-1  | }

To reproduce:

  1. Try running this function
  2. Add params: Q104587954, Q30081, Q35127 and last as language: Z1011
  3. run function and see network panel error

Wild guess: Could it be that the K4: { "Z29591K4": "Z1011" } is expected to be a different Object like{"Z1K1": "Z60", "Z60K1": "Z1011"}

Potentially related because this is also about argument references: https://phabricator.wikimedia.org/T423853

Another recent case of the same error was recorded in T423960, which I am closing. Here is the request from that ticket:

{"Z1K1":"Z7","Z7K1":{"Z1K1":"Z8","Z8K1":["Z17",{"Z1K1":"Z17","Z17K1":{"Z1K1":"Z7","Z7K1":"Z881","Z881K1":"Z1"},"Z17K2":"Z889K1","Z17K3":{"Z1K1":"Z12","Z12K1":["Z11",{"Z1K1":"Z11","Z11K1":"Z1002","Z11K2":"first list"},{"Z1K1":"Z11","Z11K1":"Z1430","Z11K2":"erste Liste"},{"Z1K1":"Z11","Z11K1":"Z1078","Z11K2":"daftar pertama"},{"Z1K1":"Z11","Z11K1":"Z1851","Z11K2":"รายการที่หนึ่ง"},{"Z1K1":"Z11","Z11K1":"Z1011","Z11K2":"প্রথম তালিকা"},{"Z1K1":"Z11","Z11K1":"Z1014","Z11K2":"ndepụta mbụ: Edepụtara ndepụta ( Ihe )"},{"Z1K1":"Z11","Z11K1":"Z1852","Z11K2":"String"},{"Z1K1":"Z11","Z11K1":"Z1004","Z11K2":"première liste"},{"Z1K1":"Z11","Z11K1":"Z1787","Z11K2":"prima lista"},{"Z1K1":"Z11","Z11K1":"Z1820","Z11K2":"पहली सूची"},{"Z1K1":"Z11","Z11K1":"Z1186","Z11K2":"רשימה ראשונה"},{"Z1K1":"Z11","Z11K1":"Z1062","Z11K2":"první seznam"}]}},{"Z1K1":"Z17","Z17K1":{"Z1K1":"Z7","Z7K1":"Z881","Z881K1":"Z1"},"Z17K2":"Z889K2","Z17K3":{"Z1K1":"Z12","Z12K1":["Z11",{"Z1K1":"Z11","Z11K1":"Z1002","Z11K2":"second list"},{"Z1K1":"Z11","Z11K1":"Z1430","Z11K2":"zweite Liste"},{"Z1K1":"Z11","Z11K1":"Z1078","Z11K2":"daftar kedua"},{"Z1K1":"Z11","Z11K1":"Z1851","Z11K2":"รายการที่สอง"},{"Z1K1":"Z11","Z11K1":"Z1011","Z11K2":"দ্বিতীয় তালিকা"},{"Z1K1":"Z11","Z11K1":"Z1014","Z11K2":"ndepụta nke abụọ: Edepụtara ndepụta ( Ihe )"},{"Z1K1":"Z11","Z11K1":"Z1852","Z11K2":"String"},{"Z1K1":"Z11","Z11K1":"Z1004","Z11K2":"deuxième liste"},{"Z1K1":"Z11","Z11K1":"Z1787","Z11K2":"seconda lista"},{"Z1K1":"Z11","Z11K1":"Z1820","Z11K2":"दूसरी सूची"},{"Z1K1":"Z11","Z11K1":"Z1186","Z11K2":"רשימה שנייה"},{"Z1K1":"Z11","Z11K1":"Z1062","Z11K2":"druhý seznam"}]}},{"Z1K1":"Z17","Z17K1":"Z8","Z17K2":"Z889K3","Z17K3":{"Z1K1":"Z12","Z12K1":["Z11",{"Z1K1":"Z11","Z11K1":"Z1002","Z11K2":"element equality function"},{"Z1K1":"Z11","Z11K1":"Z1430","Z11K2":"Funktion für die Elementen-Gleichheit"},{"Z1K1":"Z11","Z11K1":"Z1078","Z11K2":"fungsi kesamaan elemen"},{"Z1K1":"Z11","Z11K1":"Z1851","Z11K2":"ฟังก์ชันสมการสำหรับสมาชิกของรายการ"},{"Z1K1":"Z11","Z11K1":"Z1011","Z11K2":"বস্তুর সমতা ফাংশন"},{"Z1K1":"Z11","Z11K1":"Z1014","Z11K2":"ọrụ nha nhata mmewere: Ọrụ"},{"Z1K1":"Z11","Z11K1":"Z1852","Z11K2":"String"},{"Z1K1":"Z11","Z11K1":"Z1004","Z11K2":"fonction d'égalité des éléments"},{"Z1K1":"Z11","Z11K1":"Z1787","Z11K2":"funzione di uguaglianza tra elementi"},{"Z1K1":"Z11","Z11K1":"Z1820","Z11K2":"तत्वों की समानता का फ़ंक्शन"},{"Z1K1":"Z11","Z11K1":"Z1186","Z11K2":"פונקציית שוויון לפריט ברשימה"},{"Z1K1":"Z11","Z11K1":"Z1062","Z11K2":"funkce pro rovnost prvků"}]}}],"Z8K2":"Z40","Z8K3":["Z20","Z12749","Z12750","Z12751","Z12752","Z13236"],"Z8K4":["Z14","Z989"],"Z8K5":"Z889"},"Z889K1":[{"Z1K1":"Z7","Z7K1":"Z881","Z881K1":"Z6"},["Z6"]],"Z889K2":[{"Z1K1":"Z7","Z7K1":"Z881","Z881K1":"Z13518"},["Z13518"]],"Z889K3":"Z17180"}

So, the problem here doesn't have anything to do with argument references per se. Here's what is happening.

At the top level, when we try to resolve Z21583K1, we see that, when that function ran, it raised an exception. We then just raise a new exception here, completely erasing all of the original stack trace information. This is a direct consequence of the scope-lifting hack that we have done to achieve backwards-compatibility with v1. I strongly believe that we should migrate all existing functions to handle scopes correctly and undo this hack, but for the time being, we can try to wrap the outer invalid_key error with the original error information.

The original error happens because we try to access K4 of a function Z33267 which only accepts three arguments. The error manifests in the orchestrator in src/transpilation/WFFunction.js:221 or thereabouts. Here, too, we could improve the error in a few ways, but it's less clear how to do so. We'd need some information about the entire scope (i.e., a stack trace) to make this really actionable. At very least, we might want to report at least the function identity, because that's the information that helped me diagnose this on the backend.

Ultimately, the original error happens because Z33267 is called by Z29597, which is a dispatcher. Z29597 populates the argument structure of the dispatched function with four arguments, but Z33267 only accepts three arguments. So the fix would be either 1) to make the dispatcher smarter or 2) to change the argument signature of Z33267.

Jdforrester-WMF changed the task status from Open to In Progress.Jun 3 2026, 5:01 PM
Jdforrester-WMF triaged this task as High priority.

Thanks for explaining @cmassaro and thanks for fixing @Feeglgeef. Many of our dispatchers are smarter (e.g. apply3/4), but it's nice to have consistency and associated speed.

Thank you @99of9 and @Feeglgeef ! I will close this for now. Please feel free to re-open or file a new task if necessary.

At very least, we might want to report at least the function identity, because that's the information that helped me diagnose this on the backend.

Any chance you can file a report for this so we can make sure it gets done eventually? To be honest I'm not really up on how our error systems work, partly because I usually find them so unhelpful I don't bother trying because it's easier to figure out on my own!