Page MenuHomePhabricator

ZObjectFactory::create() throwing more exceptions when called from ApiPerformTest.php
Closed, ResolvedPublicBUG REPORT

Description

This is a similar problem to that fixed in https://gerrit.wikimedia.org/r/c/mediawiki/extensions/WikiLambda/+/817833/. Also, if this problem has to do with where local and global keys are supported, T315009 might be related.

Steps to replicate the issue (include links if applicable):

  • Arrange to log the exception caught at this line in ApiPerformTest.php::executeFunctionCall
		} catch ( \Exception $exception ) {

What happens?:
The page loaded above runs 4 testers; i.e. 8 calls to executeFunctionCall. The 7th and 8th of these calls (which correspond to the last, failing test) cause exceptions to be raised from ZObjectFactory::create().

(Note: As of 2022 Sept. 9, all 4 of the testers are failing on beta, whereas only the 4th is failing in my local environment. Don't know why we have this discrepancy.)

What should have happened instead?:
No exceptions

Exception logged for the 7th (test run) call:
MediaWiki\Extension\WikiLambda\ZErrorException: Key value not wellformed in /var/www/html/w/extensions/WikiLambda/includes/ZObjectFactory.php:405
Stack trace:
#0 /var/www/html/w/extensions/WikiLambda/includes/ZObjectFactory.php(314): MediaWiki\Extension\WikiLambda\ZObjectFactory::createKeyValues(Array, 'ZResponseEnvelo...')
#1 /var/www/html/w/extensions/WikiLambda/includes/ZObjectFactory.php(205): MediaWiki\Extension\WikiLambda\ZObjectFactory::createChild(Object(stdClass))
#2 /var/www/html/w/extensions/WikiLambda/includes/API/ApiPerformTest.php(241): MediaWiki\Extension\WikiLambda\ZObjectFactory::create(Object(stdClass))
#3 /var/www/html/w/extensions/WikiLambda/includes/API/ApiPerformTest.php(145): MediaWiki\Extension\WikiLambda\API\ApiPerformTest->executeFunctionCall(Object(MediaWiki\Extension\WikiLambda\ZObjects\ZFunctionCall), true)
#4 /var/www/html/w/extensions/WikiLambda/includes/API/ApiPerformTest.php(56): MediaWiki\Extension\WikiLambda\API\ApiPerformTest->run()
#5 /var/www/html/w/includes/api/ApiMain.php(1901): MediaWiki\Extension\WikiLambda\API\ApiPerformTest->execute()
#6 /var/www/html/w/includes/api/ApiMain.php(875): ApiMain->executeAction()
#7 /var/www/html/w/includes/api/ApiMain.php(846): ApiMain->executeActionWithErrorHandling()
#8 /var/www/html/w/api.php(90): ApiMain->execute()
#9 /var/www/html/w/api.php(45): wfApiMain()
#10 {main}

Exception logged for the 8th (validation run) call:
MediaWiki\Extension\WikiLambda\ZErrorException: Not wellformed in /var/www/html/w/extensions/WikiLambda/includes/ZObjectFactory.php:201
Stack trace:
#0 /var/www/html/w/extensions/WikiLambda/includes/API/ApiPerformTest.php(241): MediaWiki\Extension\WikiLambda\ZObjectFactory::create(Object(stdClass))
#1 /var/www/html/w/extensions/WikiLambda/includes/API/ApiPerformTest.php(161): MediaWiki\Extension\WikiLambda\API\ApiPerformTest->executeFunctionCall(Object(MediaWiki\Extension\WikiLambda\ZObjects\ZFunctionCall), false)
#2 /var/www/html/w/extensions/WikiLambda/includes/API/ApiPerformTest.php(56): MediaWiki\Extension\WikiLambda\API\ApiPerformTest->run()
#3 /var/www/html/w/includes/api/ApiMain.php(1901): MediaWiki\Extension\WikiLambda\API\ApiPerformTest->execute()
#4 /var/www/html/w/includes/api/ApiMain.php(875): ApiMain->executeAction()
#5 /var/www/html/w/includes/api/ApiMain.php(846): ApiMain->executeActionWithErrorHandling()
#6 /var/www/html/w/api.php(90): ApiMain->execute()
#7 /var/www/html/w/api.php(45): wfApiMain()
#8 {main}

$responseObject passed from (the test run call to) executeFunctionCall to ZObjectFactory::create():
stdClass Object
(

[Z1K1] => Z22
[Z22K1] => Z24
[Z22K2] => stdClass Object
    (
        [Z1K1] => stdClass Object
            (
                [Z1K1] => Z7
                [Z7K1] => Z883
                [Z883K1] => Z6
                [Z883K2] => Z1
            )

        [K1] => Array
            (
                [0] => stdClass Object
                    (
                        [Z1K1] => Z7
                        [Z7K1] => Z882
                        [Z882K1] => Z6
                        [Z882K2] => Z1
                    )

                [1] => stdClass Object
                    (
                        [Z1K1] => stdClass Object
                            (
                                [Z1K1] => Z7
                                [Z7K1] => Z882
                                [Z882K1] => Z6
                                [Z882K2] => Z1
                            )

                        [K1] => errors
                        [K2] => stdClass Object
                            (
                                [Z1K1] => Z5
                                [Z5K1] => stdClass Object
                                    (
                                        [Z1K1] => Z507
                                        [Z507K1] => Could not find argument Z801K1.
                                    )

                            )

                    )

                [2] => stdClass Object
                    (
                        [Z1K1] => stdClass Object
                            (
                                [Z1K1] => Z7
                                [Z7K1] => Z882
                                [Z882K1] => Z6
                                [Z882K2] => Z1
                            )

                        [K1] => orchestrationMemoryUsage
                        [K2] => 166.93 MiB
                    )

                [3] => stdClass Object
                    (
                        [Z1K1] => stdClass Object
                            (
                                [Z1K1] => Z7
                                [Z7K1] => Z882
                                [Z882K1] => Z6
                                [Z882K2] => Z1
                            )

                        [K1] => orchestrationCpuUsage
                        [K2] => 322.783 ms
                    )

                [4] => stdClass Object
                    (
                        [Z1K1] => stdClass Object
                            (
                                [Z1K1] => Z7
                                [Z7K1] => Z882
                                [Z882K1] => Z6
                                [Z882K2] => Z1
                            )

                        [K1] => orchestrationStartTime
                        [K2] => 2022-08-04T23:12:36.655Z
                    )

                [5] => stdClass Object
                    (
                        [Z1K1] => stdClass Object
                            (
                                [Z1K1] => Z7
                                [Z7K1] => Z882
                                [Z882K1] => Z6
                                [Z882K2] => Z1
                            )

                        [K1] => orchestrationEndTime
                        [K2] => 2022-08-04T23:12:36.900Z
                    )

                [6] => stdClass Object
                    (
                        [Z1K1] => stdClass Object
                            (
                                [Z1K1] => Z7
                                [Z7K1] => Z882
                                [Z882K1] => Z6
                                [Z882K2] => Z1
                            )

                        [K1] => orchestrationDuration
                        [K2] => 245 ms
                    )

            )

    )

)

The $responseObject of the validation run is too large to copy here. It's in normal form.

Event Timeline

If I run Z801 with list of strings A,B,C,D (which is the input of the failing test case mentioned above):

http://localhost:8080/wiki/Special:EvaluateFunctionCall?view=zobject-editor

it returns with no errors.

The responseObject returned by the Orchestrator has changed since this ticket was filed. The current problem with it is detailed in T324661.

In T314621#8450985, @EWright-WMF wrote:

The responseObject returned by the Orchestrator has changed since this ticket was filed. The current problem with it is detailed in T324661.

This issue is now fixed (by the patch in T324687). The remaining problem is that Z8013 is not compatible with the way we execute Testers in the PHP layer - its Z20K2 is not a call to the function under test, as the PHP layer expects. Fixing this will be covered by T299194. This ticket can now be closed.