Page MenuHomePhabricator

Z10486 seems to not pass validation
Closed, ResolvedPublicBUG REPORT

Description

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

  • call Echo(Z10486) against Wikifunctions

e.g. https://wikifunctions.beta.wmflabs.org/w/api.php?action=wikilambda_function_call&format=json&wikilambda_function_call_zobject=%7B%0A%09%22Z1K1%22%3A%20%7B%0A%09%09%22Z1K1%22%3A%20%22Z9%22%2C%0A%09%09%22Z9K1%22%3A%20%22Z7%22%0A%09%7D%2C%0A%09%22Z7K1%22%3A%20%22Z801%22%2C%0A%09%22Z801K1%22%3A%20%7B%0A%09%09%22Z1K1%22%3A%20%22Z9%22%2C%0A%09%09%22Z9K1%22%3A%20%22Z10486%22%0A%09%7D%0A%7D%0A&formatversion=2

What happens?:
The call fails with an Object type mismatch.

{

"query": {
    "wikilambda_function_call": {
        "success": true,
        "data": "{\"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\":\"Z518\",\"Z5K2\":{\"Z1K1\":{\"Z1K1\":\"Z7\",\"Z7K1\":\"Z885\",\"Z885K1\":\"Z518\"},\"Z518K1\":{\"Z1K1\":\"Z4\",\"Z4K1\":{\"Z1K1\":\"Z7\",\"Z7K1\":\"Z881\",\"Z881K1\":{\"Z1K1\":\"Z4\",\"Z4K1\":\"Z10485\",\"Z4K2\":[\"Z3\",{\"Z1K1\":\"Z3\",\"Z3K1\":\"Z10425\",\"Z3K2\":\"Z10485K1\",\"Z3K3\":{\"Z1K1\":\"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Z1K1\":\"Z3\",\"Z3K1\":\"Z10015\",\"Z3K2\":\"Z10485K2\",\"Z3K3\":{\"Z1K1\":\"Z12\",\"Z12K1\":[\"Z11\",{\"Z1K1\":\"Z11\",\"Z11K1\":\"Z1002\",\"Z11K2\":\"\"}]}}],\"Z4K3\":\"Z101\"}},\"Z3K2\":\"K2\",\"Z3K3\":{\"Z1K1\":\"Z12\",\"Z12K1\":[\"Z11\",{\"Z1K1\":\"Z11\",\"Z11K1\":\"Z1002\",\"Z11K2\":\"tail\"}]}}],\"Z4K3\":\"Z831\"},\"Z518K2\":[{\"Z1K1\":\"Z4\",\"Z4K1\":\"Z10485\",\"Z4K2\":[\"Z3\",{\"Z1K1\":\"Z3\",\"Z3K1\":\"Z10425\",\"Z3K2\":\"Z10485K1\",\"Z3K3\":{\"Z1K1\":\"Z12\",\"Z12K1\":[\"Z11\",{\"Z1K1\":\"Z11\",\"Z11K1\":\"Z1002\",\"Z11K2\":\"\"}]}},{\"Z1K1\":\"Z3\",\"Z3K1\":\"Z10015\",\"Z3K2\":\"Z10485K2\",\"Z3K3\":{\"Z1K1\":\"Z12\",\"Z12K1\":[\"Z11\",{\"Z1K1\":\"Z11\",\"Z11K1\":\"Z1002\",\"Z11K2\":\"\"}]}}],\"Z4K3\":\"Z101\"},{\"Z1K1\":\"Z10485\",\"Z10485K1\":\"Z10426\",\"Z10485K2\":{\"Z1K1\":\"Z10015\",\"Z10015K1\":\"31\"}},{\"Z1K1\":\"Z10485\",\"Z10485K1\":\"Z10427\",\"Z10485K2\":{\"Z1K1\":\"Z10015\",\"Z10015K1\":\"28\"}},{\"Z1K1\":\"Z10485\",\"Z10485K1\":\"Z10428\",\"Z10485K2\":{\"Z1K1\":\"Z10015\",\"Z10015K1\":\"31\"}},{\"Z1K1\":\"Z10485\",\"Z10485K1\":\"Z10429\",\"Z10485K2\":{\"Z1K1\":\"Z10015\",\"Z10015K1\":\"30\"}},{\"Z1K1\":\"Z10485\",\"Z10485K1\":\"Z10430\",\"Z10485K2\":{\"Z1K1\":\"Z10015\",\"Z10015K1\":\"31\"}},{\"Z1K1\":\"Z10485\",\"Z10485K1\":\"Z10431\",\"Z10485K2\":{\"Z1K1\":\"Z10015\",\"Z10015K1\":\"30\"}},{\"Z1K1\":\"Z10485\",\"Z10485K1\":\"Z10432\",\"Z10485K2\":{\"Z1K1\":\"Z10015\",\"Z10015K1\":\"31\"}},{\"Z1K1\":\"Z10485\",\"Z10485K1\":\"Z10433\",\"Z10485K2\":{\"Z1K1\":\"Z10015\",\"Z10015K1\":\"31\"}},{\"Z1K1\":\"Z10485\",\"Z10485K1\":\"Z10434\",\"Z10485K2\":{\"Z1K1\":\"Z10015\",\"Z10015K1\":\"30\"}},{\"Z1K1\":\"Z10485\",\"Z10485K1\":\"Z10435\",\"Z10485K2\":{\"Z1K1\":\"Z10015\",\"Z10015K1\":\"31\"}},{\"Z1K1\":\"Z10485\",\"Z10485K1\":\"Z10436\",\"Z10485K2\":{\"Z1K1\":\"Z10015\",\"Z10015K1\":\"30\"}},{\"Z1K1\":\"Z10485\",\"Z10485K1\":\"Z10437\",\"Z10485K2\":{\"Z1K1\":\"Z10015\",\"Z10015K1\":\"31\"}}],\"Z518K3\":{\"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\":{\"Z1K1\":\"Z7\",\"Z7K1\":\"Z882\",\"Z882K1\":\"Z6\",\"Z882K2\":\"Z1\"},\"K1\":\"orchestrationMemoryUsage\",\"K2\":\"124.66 MiB\"},{\"Z1K1\":{\"Z1K1\":\"Z7\",\"Z7K1\":\"Z882\",\"Z882K1\":\"Z6\",\"Z882K2\":\"Z1\"},\"K1\":\"orchestrationCpuUsage\",\"K2\":\"410.349 ms\"},{\"Z1K1\":{\"Z1K1\":\"Z7\",\"Z7K1\":\"Z882\",\"Z882K1\":\"Z6\",\"Z882K2\":\"Z1\"},\"K1\":\"orchestrationStartTime\",\"K2\":\"2023-01-02T23:18:03.275Z\"},{\"Z1K1\":{\"Z1K1\":\"Z7\",\"Z7K1\":\"Z882\",\"Z882K1\":\"Z6\",\"Z882K2\":\"Z1\"},\"K1\":\"orchestrationEndTime\",\"K2\":\"2023-01-02T23:18:03.894Z\"},{\"Z1K1\":{\"Z1K1\":\"Z7\",\"Z7K1\":\"Z882\",\"Z882K1\":\"Z6\",\"Z882K2\":\"Z1\"},\"K1\":\"orchestrationDuration\",\"K2\":\"619 ms\"},{\"Z1K1\":{\"Z1K1\":\"Z7\",\"Z7K1\":\"Z882\",\"Z882K1\":\"Z6\",\"Z882K2\":\"Z1\"},\"K1\":\"orchestrationHostname\",\"K2\":\"af633a9fcbcd\"}]}}"
    }
}

}

What should have happened instead?:
It should pass and return Z10486 instead.

Software version (skip for WMF-hosted wikis like Wikipedia):

Other information (browser name/version, screenshots, etc.):
No idea if the issue is with echo, or validation. The object is complicated - it is a typed list of a user-defined type - but it seems it should pass.

If Z10486 is indeed invalid, it should say something on the page of Z10486, but that looks all good.

Event Timeline

Here are the necessary files. First the type, Pair of month and positive integer, which is https://wikifunctions.beta.wmflabs.org/wiki/Z10485 on Beta:

Z10485
{
    "Z1K1": "Z2",
    "Z2K1": {
        "Z1K1": "Z6",
        "Z6K1": "Z10485"
    },
    "Z2K2": {
        "Z1K1": "Z4",
        "Z4K1": "Z10485",
        "Z4K2": [
            "Z3",
            {
                "Z1K1": "Z3",
                "Z3K1": "Z10425",
                "Z3K2": "Z10485K1",
                "Z3K3": {
                    "Z1K1": "Z12",
                    "Z12K1": [
                        "Z11",
                        {
                            "Z1K1": "Z11",
                            "Z11K1": "Z1002",
                            "Z11K2": ""
                        }
                    ]
                }
            },
            {
                "Z1K1": "Z3",
                "Z3K1": "Z10015",
                "Z3K2": "Z10485K2",
                "Z3K3": {
                    "Z1K1": "Z12",
                    "Z12K1": [
                        "Z11",
                        {
                            "Z1K1": "Z11",
                            "Z11K1": "Z1002",
                            "Z11K2": ""
                        }
                    ]
                }
            }
        ],
        "Z4K3": "Z101"
    },
    "Z2K3": {
        "Z1K1": "Z12",
        "Z12K1": [
            "Z11",
            {
                "Z1K1": "Z11",
                "Z11K1": "Z1002",
                "Z11K2": "Pair of month and positive integer"
            }
        ]
    },
    "Z2K4": {
        "Z1K1": "Z32",
        "Z32K1": [
            "Z31"
        ]
    }
}

And this is the value:

Z10486
{
    "Z1K1": "Z2",
    "Z2K1": {
        "Z1K1": "Z6",
        "Z6K1": "Z10486"
    },
    "Z2K2": [
        "Z10485",
        {
            "Z1K1": "Z10485",
            "Z10485K1": "Z10426",
            "Z10485K2": {
                "Z1K1": "Z10015",
                "Z10015K1": "31"
            }
        },
        {
            "Z1K1": "Z10485",
            "Z10485K1": "Z10427",
            "Z10485K2": {
                "Z1K1": "Z10015",
                "Z10015K1": "28"
            }
        },
        {
            "Z1K1": "Z10485",
            "Z10485K1": "Z10428",
            "Z10485K2": {
                "Z1K1": "Z10015",
                "Z10015K1": "31"
            }
        },
        {
            "Z1K1": "Z10485",
            "Z10485K1": "Z10429",
            "Z10485K2": {
                "Z1K1": "Z10015",
                "Z10015K1": "30"
            }
        },
        {
            "Z1K1": "Z10485",
            "Z10485K1": "Z10430",
            "Z10485K2": {
                "Z1K1": "Z10015",
                "Z10015K1": "31"
            }
        },
        {
            "Z1K1": "Z10485",
            "Z10485K1": "Z10431",
            "Z10485K2": {
                "Z1K1": "Z10015",
                "Z10015K1": "30"
            }
        },
        {
            "Z1K1": "Z10485",
            "Z10485K1": "Z10432",
            "Z10485K2": {
                "Z1K1": "Z10015",
                "Z10015K1": "31"
            }
        },
        {
            "Z1K1": "Z10485",
            "Z10485K1": "Z10433",
            "Z10485K2": {
                "Z1K1": "Z10015",
                "Z10015K1": "31"
            }
        },
        {
            "Z1K1": "Z10485",
            "Z10485K1": "Z10434",
            "Z10485K2": {
                "Z1K1": "Z10015",
                "Z10015K1": "30"
            }
        },
        {
            "Z1K1": "Z10485",
            "Z10485K1": "Z10435",
            "Z10485K2": {
                "Z1K1": "Z10015",
                "Z10015K1": "31"
            }
        },
        {
            "Z1K1": "Z10485",
            "Z10485K1": "Z10436",
            "Z10485K2": {
                "Z1K1": "Z10015",
                "Z10015K1": "30"
            }
        },
        {
            "Z1K1": "Z10485",
            "Z10485K1": "Z10437",
            "Z10485K2": {
                "Z1K1": "Z10015",
                "Z10015K1": "31"
            }
        }
    ],
    "Z2K3": {
        "Z1K1": "Z12",
        "Z12K1": [
            "Z11",
            {
                "Z1K1": "Z11",
                "Z11K1": "Z1002",
                "Z11K2": "list of days in Gregorian calendar month in standard year"
            }
        ]
    },
    "Z2K4": {
        "Z1K1": "Z32",
        "Z32K1": [
            "Z31"
        ]
    }
}

Echo on this object (which is identical to Z10486, except the list has no elements) succeeds: https://wikifunctions.beta.wmflabs.org/wiki/Z10558
Echo on this object (which is identical to the above but with an element) fails: https://wikifunctions.beta.wmflabs.org/wiki/Z10559

This is a bug in the Orchestrator's validation logic. Suppose we have:

  1. A type Z10001 which has a single key Z10001K1 of type Z6.
  2. Another type Z10002, which has a single key Z10002K1, also of type Z6.
  3. A third type Z10003, with two keys: Z10003K1 which is of type Z10001, and Z10003K2 which is of type Z10002.
  4. An object Z10004 which is an instance of type Z10003.

When the Orchestrator validates Z10004 it iterates over Z10003's keys and creates a validator for each. It avoid creating duplicate validators by checking whether a validator for an identical type already exists in its cache.

We end up with the following sequence of events:

  1. For Z10003K1 it creates a new validator for Z10001 under the unique identifier "<Z6>" (because Z10001 has a single key of type Z6 - see code here).
  2. For Z10003K2, it does *not* create a validator for Z10002. This is because Z10002 is represented by the same unique identifier "<Z6>", and there's already a cached validator for that identifier.
  3. Later, when it comes to actually validate the value of Z10003K2 in Z10004, it fails, because that value contains Z10002K1, but the validator under "<Z6>" is expecting the key Z10001K1.

@EWright-WMF , thank you for digging into this! I'm amazed that these identifiers haven't blown up before and very grateful you're looking at them now that they have.

Change 883178 had a related patch set uploaded (by EWright; author: EWright):

[mediawiki/services/function-schemata@master] [WIP] Make unique identifer for type more unique.

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

Change 883178 merged by jenkins-bot:

[mediawiki/services/function-schemata@master] Make unique identifer for user-defined types more unique.

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

Change 883194 had a related patch set uploaded (by EWright; author: EWright):

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

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

Change 883195 had a related patch set uploaded (by EWright; author: EWright):

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

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

Change 883244 had a related patch set uploaded (by Genoveva Galarza; author: Genoveva Galarza):

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

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

Change 883194 merged by jenkins-bot:

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

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

Change 883244 merged by jenkins-bot:

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

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

Change 883195 merged by jenkins-bot:

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

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

Yay! Thank you for fixing this!

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

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

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

Change 883637 merged by jenkins-bot:

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

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