Page MenuHomePhabricator

Sometimes the first argument for value by key is incomplete
Closed, ResolvedPublicBUG REPORT

Assigned To
Authored By
DVrandecic
Mar 20 2024, 10:48 PM
Referenced Files
F59019871: image.png
Apr 8 2025, 11:51 PM
F59019854: image.png
Apr 8 2025, 11:51 PM
F59019846: image.png
Apr 8 2025, 11:51 PM
F57367750: IMG_1002.png
Aug 31 2024, 9:12 AM
F57366329: IMG_1001.png
Aug 31 2024, 6:45 AM
F56464849: IMG_0975.png
Jul 16 2024, 5:36 PM
F42885289: value by key good.png
Mar 20 2024, 10:48 PM
F42885261: value by key bad.png
Mar 20 2024, 10:48 PM

Description

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

What happens?:
Sometimes the first argument shows a type, but no reference field to enter the key reference.

value by key bad.png (303×327 px, 16 KB)

What should have happened instead?:

The reference field should have been displayed.

value by key good.png (407×321 px, 21 KB)

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

Other information (browser name/version, screenshots, etc.):

Sometimes it gets displayed when I reload.
When I am in a composition, trying to use value by key, I can sometimes switch the function and then back to value by key and then it loads fine.

It is not completely deterministic.

Event Timeline

Jdforrester-WMF moved this task from To Triage to Backlog on the Abstract Wikipedia team board.

I am trying really hard to replicate this. But i always see a reference field. We need a bit more steps I think.

I also cannot replicate it as of today, tried several ways. Maybe has been serendipitously fixed. Shall we close it?

Ah so this might clarify this ticket.

Steps to reproduce are then:

  1. go to https://www.wikifunctions.org/view/en/Z803
  2. press + add test
  3. See how 'Key reference' is disabled and there is not reference field below

@DVrandecic should we reopen?

This bug has not been fixed. It seems to occur exactly once when adding a test to Z803 or using the function in any composition (implementation or tester).

IMG_1001.png (2×960 px, 293 KB)
Tester for Z803

IMG_1002.png (2×960 px, 324 KB)
Tester for a different function

Adding “same Key” (https://www.wikifunctions.org/view/en/Z19108), I noticed the same problem when adding an implementation or test. The problem also occurs on Z17359, so it looks like it is a general problem with a Key reference. As noted before, the problem occurs exactly once whenever a Key reference is expected.

Adding “same Key” (https://www.wikifunctions.org/view/en/Z19108), I noticed the same problem when adding an implementation or test. The problem also occurs on Z17359, so it looks like it is a general problem with a Key reference. As noted before, the problem occurs exactly once whenever a Key reference is expected.

When attempting to add a test case to Z22499, which expects two Key references, both exhibit the same problem.

This is a very common problem. If anyone comes here frustrated before the bug is fixed, it might help to note that there is a way around to switch object type and switch back to reference.

This is a very common problem. If anyone comes here frustrated before the bug is fixed, it might help to note that there is a way around to switch object type and switch back to reference.

It may not “just work” but I proposed a read function at https://www.wikifunctions.org/wiki/Talk:Z39

I did some investigation.
first findings:

  1. zobject.js store -> setZFunctionCallArguments: this is where it goes wrong. At the end of the function the arguments should have been added. We see a clear difference between the state.zobject for the page itself (function evaluator) and the Special:Runfunction/tests page where for argument 1 the Z39K1 is missing in the zobject table

Good structure:

{
    "id": 292, // Argument 1
    "key": "Z803K1",
    "parent": 284,
    "value": 1
},
{
    "id": 293, // Argument 1 key reference 
    "key": "Z1K1",
    "parent": 292,
    "value": 1
},
{
    "id": 294,
    "key": "Z1K1",
    "parent": 293,
    "value": "Z9"
},
{
    "id": 295,
    "key": "Z9K1",
    "parent": 293,
    "value": "Z39"
},
{
    "id": 296,// Argument 1 key reference value
    "key": "Z39K1",
    "parent": 292,
    "value": 1
},
{
    "id": 297,
    "key": "Z1K1",
    "parent": 296,
    "value": "Z6"
},
{
    "id": 298,
    "key": "Z6K1",
    "parent": 296,
    "value": ""
},
{
    "id": 299,// Argument 2
    "key": "Z803K2",
    "parent": 284,
    "value": 1
},

Wong structure:

 {
        "id": 15, // Argument 1
        "key": "Z803K1",
        "parent": 7,
        "value": 1
    },
    {
        "id": 16, // Argument 1 key reference
        "key": "Z1K1",
        "parent": 15,
        "value": 1
    },
    {
        "id": 17,
        "key": "Z1K1",
        "parent": 16,
        "value": "Z9"
    },
    {
        "id": 18,
        "key": "Z9K1",
        "parent": 16,
        "value": "Z39"
    },
>>> We need argument 1 key reference value here <<<
    {
        "id": 19, // Argument 2
        "key": "Z803K2",
        "parent": 7,
        "value": 1
    },
  1. The code in setZFunctionCallArguments where it goes wrong.

This code gives a different result for the 2 use cases:

const value = this.createObjectByType( {
  type: arg[ Constants.Z_ARGUMENT_TYPE ]
} );

The correct one returns: {Z1K1: 'Z39', Z39K1: ''}.
The wrong one returns: {Z1K1: 'Z39'}

In createObjectByType when creating a generic object it tries to get the persistent object for Z39: const persisted = this.getStoredObject( payload.type );

This returns undefined in the tester page and runFunction page. Therefor the code afterwards (isPersisted) is not ran and results in:

{Z1K1: 'Z39'}

Instead of:

{Z1K1: 'Z39', Z39K1: ''}

TODO:

  • should we check where we need to fetch the Z39 / arguments in an earlier stage?
  • should we account in the component for a format of {Z1K1: 'Z39'}?
  • in createGenericObject could we add a default when isPersisted is false?
const value = {
  [ Constants.Z_OBJECT_TYPE ]: payload.type,
  [ `Z${ payload.type }K1` ]: '' // add this default
};

Change #1131325 had a related patch set uploaded (by Daphne Smit; author: Daphne Smit):

[mediawiki/extensions/WikiLambda@master] FunctionEvaluator: Sometimes the first argument for 'value by key/Z803' is incomplete

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

Change #1131325 merged by jenkins-bot:

[mediawiki/extensions/WikiLambda@master] FunctionEvaluator: Sometimes the first argument for 'value by key/Z803' is incomplete

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

I'm still not sure this is resolved. When I follow the instructions here:
Steps to reproduce are then:

I get this:

image.png (81×294 px, 3 KB)

Then I expand the carrot and I get this:

image.png (383×340 px, 10 KB)

(note that the key does not have a value field)

Then only by switching the type of the key back and forward can I get the correct interface:

image.png (457×335 px, 11 KB)

I'm still not sure this is resolved…

Agreed. it isn’t resolved. This is the second time this bug has been closed while the problem persists. Perhaps someone could check with us next time?

Change #1163744 had a related patch set uploaded (by Daphne Smit; author: Daphne Smit):

[mediawiki/extensions/WikiLambda@master] ZTester.vue: fix sometimes the first argument for value by key is incomplete

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

Change #1163744 abandoned by Daphne Smit:

[mediawiki/extensions/WikiLambda@master] ZTester.vue: fix sometimes the first argument for value by key is incomplete

Reason:

Geno fixed in the big refactor

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