Page MenuHomePhabricator

Orchestrator does not pass down error to PHP layer
Closed, ResolvedPublicBUG REPORT

Description

Description

Steps to reproduce (step by step instructions, with links, commands and necessary data to reproduce the error)

  • Run local mediawiki targeting local orchestrator
  • Misconfigure the evaluator's address, so that orchestrator will not be able to reach it: edit docker-compose.override.yml so that FUNCTION_EVALUATOR_URL is incorrect.
  • In the UI, create a function, then create a tester and code implementation for it - any should work
  • Go to the tester's page so that the tester is performed on the implementation.

Observed behavior

  • Looking at the orchestrator's logs with docker logs mediawiki-function-orchestrator-1 we can see:
{
	"name": "function-orchestrator",
	"hostname": "b2bbdab2c42f",
	"pid": 1,
	"level": 50,
	"levelPath": "error",
	"msg": "Call tuples failed in returnOnFirstError. Error: FetchError: request to http://mediawiki-function-evaluatooooooor-1:6927/1/v1/evaluate/ failed, reason: getaddrinfo ENOTFOUND mediawiki-function-evaluatooooooor-1.",
	"time": "2022-10-21T11:25:33.312Z",
	"v": 0
}
  • But we can also see that its response to the PHP layer does not note any error:
{
	"name": "function-orchestrator",
	"hostname": "b2bbdab2c42f",
	"pid": 1,
	"level": 10,
	"msg": "Outgoing response",
	"response": {
		"Z1K1": "Z22",
		"Z22K1": {
			"Z1K1": "Z7",
			"Z7K1": {
				"Z1K1": "Z8",
				"Z8K1": [
					"Z17",
					{
						"Z1K1": "Z17",
						"Z17K1": "Z6",
						"Z17K2": "Z10037K1",
						"Z17K3": {
							"Z1K1": "Z12",
							"Z12K1": [
								"Z11",
								{
									"Z1K1": "Z11",
									"Z11K1": "Z1002",
									"Z11K2": "input"
								}
							]
						}
					}
				],
				"Z8K2": "Z6",
				"Z8K3": [
					"Z20",
					"Z10038"
				],
				"Z8K4": [
					"Z14",
					"Z10039"
				],
				"Z8K5": "Z10037"
			},
			"Z10037K1": "input that doesn't matter"
		},
		"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": "orchestrationMemoryUsage",
					"K2": "134.03 MiB"
				},
				{
					"Z1K1": {
						"Z1K1": "Z7",
						"Z7K1": "Z882",
						"Z882K1": "Z6",
						"Z882K2": "Z1"
					},
					"K1": "orchestrationCpuUsage",
					"K2": "1075.2 ms"
				},
				{
					"Z1K1": {
						"Z1K1": "Z7",
						"Z7K1": "Z882",
						"Z882K1": "Z6",
						"Z882K2": "Z1"
					},
					"K1": "orchestrationStartTime",
					"K2": "2022-10-21T11:25:32.706Z"
				},
				{
					"Z1K1": {
						"Z1K1": "Z7",
						"Z7K1": "Z882",
						"Z882K1": "Z6",
						"Z882K2": "Z1"
					},
					"K1": "orchestrationEndTime",
					"K2": "2022-10-21T11:25:33.312Z"
				},
				{
					"Z1K1": {
						"Z1K1": "Z7",
						"Z7K1": "Z882",
						"Z882K1": "Z6",
						"Z882K2": "Z1"
					},
					"K1": "orchestrationDuration",
					"K2": "606 ms"
				},
				{
					"Z1K1": {
						"Z1K1": "Z7",
						"Z7K1": "Z882",
						"Z882K1": "Z6",
						"Z882K2": "Z1"
					},
					"K1": "orchestrationHostname",
					"K2": "b2bbdab2c42f"
				}
			]
		}
	},
	"x-request-id": "13471180-5133-11ed-9134-c91efaa6c21f",
	"levelPath": "trace/req",
	"time": "2022-10-21T11:25:33.337Z",
	"v": 0
}

Expected behavior/Acceptance criteria (returned value, expected error, performance expectations, etc.)

The orchestrator's response should note there was an error.


Completion checklist

Event Timeline

We discussed this today in the Meta-data working group; this is definitely something we should fix, and is on the border between the 'meta-data' work we're finishing and the 'back-end errors' work we're starting, so this works out.

The logging is done here, in orchestrate.js:

	try {
		currentResponseEnvelope = await returnOnFirstError( currentResponseEnvelope, callTuples );
	} catch ( e ) {
		logger.error( `Call tuples failed in returnOnFirstError. Error: ${e}.` );
	}

Probably, in addition to the logging, we should wrap the caught error in a ZError, put the ZError in Z22K2 and void in Z22K1, and immediately return the Z22. To wrap the caught error, we should have a utility function similar to wrapMessageInZError in the PHP layer.

We should also check if the caught error is an instance of ZResponseError (a custom Error that carries a ZObject). In such a case, the handling would be a little different.

Change 861923 had a related patch set uploaded (by David Martin; author: David Martin):

[mediawiki/services/function-schemata@master] New utility function wrapMessageInEvaluationError

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

Change 862320 had a related patch set uploaded (by David Martin; author: David Martin):

[mediawiki/services/function-orchestrator@master] Convert caught JS errors to ZErrors and return them

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

Change 861923 merged by jenkins-bot:

[mediawiki/services/function-schemata@master] New utility function wrapMessageInEvaluationError

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

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

[mediawiki/services/function-evaluator@master] Update function-schemata sub-module to HEAD (a363827)

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

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

[mediawiki/services/function-orchestrator@master] Update function-schemata sub-module to HEAD (a363827)

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

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

[mediawiki/tools/wikilambda-cli@master] Update function-schemata sub-module to HEAD (a363827)

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

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

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

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

Change 865699 merged by jenkins-bot:

[mediawiki/tools/wikilambda-cli@master] Update function-schemata sub-module to HEAD (a363827)

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

Change 865697 merged by jenkins-bot:

[mediawiki/services/function-orchestrator@master] Update function-schemata sub-module to HEAD (a363827)

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

Change 865700 merged by jenkins-bot:

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

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

Change 865698 merged by jenkins-bot:

[mediawiki/services/function-evaluator@master] Update function-schemata sub-module to HEAD (a363827)

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

Change 862320 merged by jenkins-bot:

[mediawiki/services/function-orchestrator@master] Convert caught JS errors to ZErrors and return them

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