Page MenuHomePhabricator

Execution of Z885( Z511 ) fails
Closed, ResolvedPublic

Description

Steps to reproduce

  • With the API wikilambda_function_call run the following function
{
  "Z1K1":"Z7",
  "Z7K1":"Z885",
  "Z885K1":"Z511"
}

Observed behavior

  • The function call returns the following error:
{
	"Z1K1": "Z22",
	"Z22K1": "Z24",
	"Z22K2": {
		"Z1K1": {
			"Z1K1": "Z7",
			"Z7K1": "Z883",
			"Z883K1": "Z6",
			"Z883K2": "Z1"
		},
		"K1": [{
			"Z1K1": "Z7",
			"Z7K1": "Z882",
			"Z882K1": "Z6",
			"Z882K2": "Z1"
		}, {
			"Z1K1": {
				"Z1K1": "Z7",
				"Z7K1": "Z882",
				"Z882K1": "Z6",
				"Z882K2": "Z1"
			},
			"K1": "errors",
			"K2": {
				"Z1K1": "Z5",
				"Z5K1": {
					"Z1K1": "Z517",
					"Z517K1": "Z4",
					"Z517K2": "Z4",
					"Z517K3": {
						"Z1K1": "Z4",
						"Z4K1": {
							"Z1K1": "Z7",
							"Z7K1": "Z885",
							"Z885K1": {
								"Z1K1": "Z18",
								"Z18K1": "Z885K1"
							}
						},
						"Z4K2": {
							"Z1K1": "Z7",
							"Z7K1": "Z803",
							"Z803K1": {
								"Z1K1": "Z39",
								"Z39K1": "Z50K1"
							},
							"Z803K2": {
								"Z1K1": "Z18",
								"Z18K1": "Z885K1"
							}
						},
						"Z4K3": "Z101"
					},
					"Z517K4": {
						"Z1K1": "Z5",
						"Z5K1": "Z502",
						"Z5K2": {
							"Z1K1": {
								"Z1K1": "Z7",
								"Z7K1": "Z885",
								"Z885K1": "Z502"
							},
							"Z502K1": "Z509",
							"Z502K2": {
								"Z1K1": "Z5",
								"Z5K1": "Z509",
								"Z5K2": {
									"Z1K1": {
										"Z1K1": "Z7",
										"Z7K1": "Z885",
										"Z885K1": "Z509"
									},
									"Z509K1": ["Z5", {
										"Z1K1": "Z5",
										"Z5K1": "Z526",
										"Z5K2": {
											"Z1K1": {
												"Z1K1": "Z7",
												"Z7K1": "Z885",
												"Z885K1": "Z526"
											},
											"Z526K1": {
												"Z1K1": "Z39",
												"Z39K1": "Z4K2"
											},
											"Z526K2": {
												"Z1K1": "Z5",
												"Z5K1": "Z509",
												"Z5K2": {
													"Z1K1": {
														"Z1K1": "Z7",
														"Z7K1": "Z885",
														"Z885K1": "Z509"
													},
													"Z509K1": ["Z5", {
														"Z1K1": "Z5",
														"Z5K1": "Z525",
														"Z5K2": {
															"Z1K1": {
																"Z1K1": "Z7",
																"Z7K1": "Z885",
																"Z885K1": "Z525"
															},
															"Z525K1": "Z7K1"
														}
													}, {
														"Z1K1": "Z5",
														"Z5K1": "Z511",
														"Z5K2": {
															"Z1K1": {
																"Z1K1": "Z7",
																"Z7K1": "Z885",
																"Z885K1": "Z511"
															},
															"Z511K1": {
																"Z1K1": "Z39",
																"Z39K1": "K1"
															},
															"Z511K2": {
																"Z1K1": "Z99",
																"Z99K1": {
																	"Z1K1": "Z7",
																	"Z7K1": "Z803",
																	"Z803K1": {
																		"Z1K1": "Z39",
																		"Z39K1": "Z50K1"
																	},
																	"Z803K2": {
																		"Z1K1": "Z18",
																		"Z18K1": "Z885K1"
																	}
																}
															}
														}
													}]
												}
											}
										}
									}, {
										"Z1K1": "Z5",
										"Z5K1": "Z535",
										"Z5K2": {
											"Z1K1": {
												"Z1K1": "Z7",
												"Z7K1": "Z885",
												"Z885K1": "Z535"
											},
											"Z535K1": {
												"Z1K1": "Z99",
												"Z99K1": {
													"Z1K1": "Z4",
													"Z4K1": {
														"Z1K1": "Z7",
														"Z7K1": "Z885",
														"Z885K1": {
															"Z1K1": "Z18",
															"Z18K1": "Z885K1"
														}
													},
													"Z4K2": {
														"Z1K1": "Z7",
														"Z7K1": "Z803",
														"Z803K1": {
															"Z1K1": "Z39",
															"Z39K1": "Z50K1"
														},
														"Z803K2": {
															"Z1K1": "Z18",
															"Z18K1": "Z885K1"
														}
													},
													"Z4K3": "Z101"
												}
											}
										}
									}, {
										"Z1K1": "Z5",
										"Z5K1": "Z511",
										"Z5K2": {
											"Z1K1": {
												"Z1K1": "Z7",
												"Z7K1": "Z885",
												"Z885K1": "Z511"
											},
											"Z511K1": {
												"Z1K1": "Z39",
												"Z39K1": "Z18K1"
											},
											"Z511K2": {
												"Z1K1": "Z99",
												"Z99K1": {
													"Z1K1": "Z4",
													"Z4K1": {
														"Z1K1": "Z7",
														"Z7K1": "Z885",
														"Z885K1": {
															"Z1K1": "Z18",
															"Z18K1": "Z885K1"
														}
													},
													"Z4K2": {
														"Z1K1": "Z7",
														"Z7K1": "Z803",
														"Z803K1": {
															"Z1K1": "Z39",
															"Z39K1": "Z50K1"
														},
														"Z803K2": {
															"Z1K1": "Z18",
															"Z18K1": "Z885K1"
														}
													},
													"Z4K3": "Z101"
												}
											}
										}
									}]
								}
							}
						}
					}
				}
			}
		}, {
			"Z1K1": {
				"Z1K1": "Z7",
				"Z7K1": "Z882",
				"Z882K1": "Z6",
				"Z882K2": "Z1"
			},
			"K1": "orchestrationMemoryUsage",
			"K2": "145.61 MiB"
		}, {
			"Z1K1": {
				"Z1K1": "Z7",
				"Z7K1": "Z882",
				"Z882K1": "Z6",
				"Z882K2": "Z1"
			},
			"K1": "orchestrationCpuUsage",
			"K2": "76.994 ms"
		}, {
			"Z1K1": {
				"Z1K1": "Z7",
				"Z7K1": "Z882",
				"Z882K1": "Z6",
				"Z882K2": "Z1"
			},
			"K1": "orchestrationStartTime",
			"K2": "2022-08-19T08:17:00.957Z"
		}, {
			"Z1K1": {
				"Z1K1": "Z7",
				"Z7K1": "Z882",
				"Z882K1": "Z6",
				"Z882K2": "Z1"
			},
			"K1": "orchestrationEndTime",
			"K2": "2022-08-19T08:17:01.291Z"
		}, {
			"Z1K1": {
				"Z1K1": "Z7",
				"Z7K1": "Z882",
				"Z882K1": "Z6",
				"Z882K2": "Z1"
			},
			"K1": "orchestrationDuration",
			"K2": "334 ms"
		}]
	}
}

Object returned by the evaluator:

{
	"Z1K1": "Z4",
	"Z4K1": {
		"Z1K1": "Z7",
		"Z7K1": "Z885",
		"Z885K1": {
			"Z1K1": "Z18",
			"Z18K1": "Z885K1"
		}
	},
	"Z4K2": {
		"Z1K1": "Z7",
		"Z7K1": "Z803",
		"Z803K1": {
			"Z1K1": "Z39",
			"Z39K1": "Z50K1"
		},
		"Z803K2": {
			"Z1K1": "Z18",
			"Z18K1": "Z885K1"
		}
	},
	"Z4K3": "Z101"
}

This raises two issues

Issue 1

While the returned zObject is correct, it lacks the key information as the value for Z4K2 has not been evaluated, so instead of having a type with the list of keys, we have just another function call to Z803. In this particular case, I believe the object should be evaluated a level further and instead of returning the object above, return the following:

{
	"Z1K1": "Z4",
	"Z4K1": {
		"Z1K1": "Z7",
		"Z7K1": "Z885",
		"Z885K1": {
			"Z1K1": "Z18",
			"Z18K1": "Z885K1"
		}
	},
	"Z4K2": [
		"Z3",
		{
			"Z1K1": "Z3",
			"Z3K1": "Z39",
			"Z3K2": "Z511K1",
			"Z3K3": {
				"Z1K1": "Z12",
				"Z12K1": [
					"Z11",
					{
						"Z1K1": "Z11",
						"Z11K1": "Z1002",
						"Z11K2": "key"
					}
				]
			}
		},
		{
			"Z1K1": "Z3",
			"Z3K1": "Z99",
			"Z3K2": "Z511K2",
			"Z3K3": {
				"Z1K1": "Z12",
				"Z12K1": [
					"Z11",
					{
						"Z1K1": "Z11",
						"Z11K1": "Z1002",
						"Z11K2": "object"
					}
				]
			}
		}
	],
	"Z4K3": "Z101"
}
Issue 2

While the returned object is not what we should expect, it is valid. However it is being tagged as non valid by function-schemata. What we can tell about the error above (value of Z517K4) is:

  • It's a validation error on the key "Z4K2"
  • The value for Z4K2 has the following errors:
    • Invalid key Z7K1
    • Key "K1" not found in the function call to Z803

The errors returned are quite puzzling

Details

TitleReferenceAuthorSource BranchDest Branch
Update function-schemata sub-module to HEAD (5f40813)repos/abstract-wiki/wikifunctions/function-evaluator!29jforrestersync-function-schematamain
Update function-schemata sub-module to HEAD (5f40813)repos/abstract-wiki/wikifunctions/wikilambda-cli!12jforrestersync-function-schematamain
BREAKING CHANGE: Update function-schemata sub-module to HEAD (63aa93e)repos/abstract-wiki/wikifunctions/function-orchestrator!35apineapine-sync-function-schematamain
Implement builtin for errortype-to-type.repos/abstract-wiki/wikifunctions/function-orchestrator!31apineapine-Z885-builtinmain
Switch Z985 to a built-in implementation.repos/abstract-wiki/wikifunctions/function-schemata!18apineapine-Z885-builtinmain
Draft: Eagerly evaluate function return values.repos/abstract-wiki/wikifunctions/function-orchestrator!30apineapine-eagerly-evaluate-resultmain
Customize query in GitLab

Event Timeline

gengh updated the task description. (Show Details)
DVrandecic renamed this task from Execution of Z885( 5?? ) fails to Execution of Z885( Z511 ) fails.Jan 11 2023, 12:32 AM
Jdforrester-WMF raised the priority of this task from Medium to High.Jan 11 2023, 8:23 PM

As of re-checking today, the output is now not an error, but:

{
    "Z1K1": "Z4",
    "Z4K1": {
        "Z1K1": "Z7",
        "Z7K1": "Z885",
        "Z885K1": "Z511"
    },
    "Z4K2": {
        "Z1K1": "Z7",
        "Z7K1": "Z803",
        "Z803K1": {
            "Z1K1": "Z39",
            "Z39K1": "Z50K1"
        },
        "Z803K2": "Z511"
    },
    "Z4K3": "Z101"
}

This is different, but clearly wrong (the Z4K2 needs to be a list).

Interesting! This is due to a confluence of hacks.

First, we don't eagerly evaluate execution results. Arguably, we should do that, although this will make the orchestrator slower. I have made an MR to make this change in the orchestrator.

While this change will fix potential future problems with half-resolved compositions, it does not fix the current problem. This is because of the heuristics we use to avoid infinite expansion of eagerly evaluated objects. Here, the fix is just to make Z885 a built-in function instead of a composition.

Do people think my MR is worth merging? Does anyone object to my rewriting Z885 as a built-in function?

If we want to re-write as a built-in, there are MRs in function-orchestrator and function-schemata tagged against this bug

The result is now valid. It still misses the internal evaluation of Z4K2, but I filed a separate bug for that:

https://phabricator.wikimedia.org/T341163

Declaring this closed.

Change 938017 had a related patch set uploaded (by Jforrester; author: Jforrester):

[mediawiki/extensions/WikiLambda@master] Update function-schemata sub-module to HEAD (5f40813)

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

Change 938017 merged by jenkins-bot:

[mediawiki/extensions/WikiLambda@master] Update function-schemata sub-module to HEAD (5cc2fc7)

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