Page MenuHomePhabricator

Uncaught TypeError: can't access property "difficulty", this.taskType is undefined
Closed, ResolvedPublicBUG REPORT

Description

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

  • Complete 5 copyedit tasks on testwiki
  • Click "Try new task" when prompted to try "links"

What happens?:

Uncaught TypeError: can't access property "difficulty", this.taskType is undefined
   buildCard https://test.wikipedia.org/w/index.php?title=Wright_&_Wright_Architects&gesuggestededit=1 line 10 > injectedScript:28
   SmallTaskCard https://test.wikipedia.org/w/index.php?title=Wright_&_Wright_Architects&gesuggestededit=1 line 10 > injectedScript:26
   getCard https://test.wikipedia.org/w/index.php?title=Wright_&_Wright_Architects&gesuggestededit=1 line 10 > injectedScript:15
   updateTask https://test.wikipedia.org/w/index.php?title=Wright_&_Wright_Architects&gesuggestededit=1 line 10 > injectedScript:16
   updateNextTask https://test.wikipedia.org/w/index.php?title=Wright_&_Wright_Architects&gesuggestededit=1 line 10 > injectedScript:17

The failing code:

$taskType = $('<span>').addClass('mw-ge-small-task-card-tasktype').addClass('mw-ge-small-task-card-tasktype-difficulty-' + this.taskType.difficulty).prepend(new OO.ui.IconWidget({
              icon: 'difficulty-' + this.taskType.difficulty
            }).$element);

The post-edit dialog appears in a "loading" state.

What should have happened instead?:

The post-edit dialog should contain "links" tasks.

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

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

Event Timeline

kostajh triaged this task as High priority.Mar 16 2023, 1:11 PM
kostajh updated the task description. (Show Details)

Seems like a consequence of rEGREf323bd17781e: Post edit panel: do not wait for tasks request to show the panel; this.taskType is only set if config.task is supplied, and that is now optional, but in buildCard, we only check for config.task.

Seems like a consequence of rEGREf323bd17781e: Post edit panel: do not wait for tasks request to show the panel; this.taskType is only set if config.task is supplied, and that is now optional, but in buildCard, we only check for config.task.

Hmm, maybe it is not related to that, because I can't reproduce locally. One thing that is suspicious is that I am being prompted to try "links", but that is not an active task type on testwiki:

image.png (1×1 px, 210 KB)

The query (https://test.wikipedia.org/w/api.php?action=query&format=json&meta=growthnextsuggestedtasktype&formatversion=2&gnsttactivetasktype=copyedit) to get the next suggested task type looks at all task types, but I suspect needs to be modified to ensure that it only returns active task types as suggestions:

{
    "batchcomplete": true,
    "query": {
        "growthnextsuggestedtasktype": null,
        "editcountbytasktype": {
            "copyedit": 10,
            "expand": 0,
            "image-recommendation": 7,
            "link-recommendation": 25,
            "links": 0,
            "references": 0,
            "update": 0
        }
    }
}

Seems like a consequence of rEGREf323bd17781e: Post edit panel: do not wait for tasks request to show the panel; this.taskType is only set if config.task is supplied, and that is now optional, but in buildCard, we only check for config.task.

Hmm, maybe it is not related to that, because I can't reproduce locally. One thing that is suspicious is that I am being prompted to try "links", but that is not an active task type on testwiki:

image.png (1×1 px, 210 KB)

The query (https://test.wikipedia.org/w/api.php?action=query&format=json&meta=growthnextsuggestedtasktype&formatversion=2&gnsttactivetasktype=copyedit) to get the next suggested task type looks at all task types, but I suspect needs to be modified to ensure that it only returns active task types as suggestions:

{
    "batchcomplete": true,
    "query": {
        "growthnextsuggestedtasktype": null,
        "editcountbytasktype": {
            "copyedit": 10,
            "expand": 0,
            "image-recommendation": 7,
            "link-recommendation": 25,
            "links": 0,
            "references": 0,
            "update": 0
        }
    }
}

Ah, I think this is happening because we don't mark links as disabled, but instead swap it out with link-recommendation when that is available. (We did that for A/B testing purposes.) So when PageConfigurationLoader::parseTaskTypesFromConfig gets the config, it adds the disabled task type to the list.

We either need to make links disabled everywhere that link-recommendation is enabled, or find some other way to special case the way we handle links / link-recommendation in LevelingUpManager.

After going through the steps to reproduce once and seeing the described error I'm not longer able to reproduce the error because I get a different one:

jQuery.Deferred exception: Cannot read properties of null (reading 'indexOf') TypeError: Cannot read properties of null (reading 'indexOf')
    at Object.setupTryNewTaskPanel (<anonymous>:5:803)
    at <anonymous>:9:525
    at mightThrow (https://test.wikipedia.org/w/load.php?lang=en&modules=jquery%2Coojs-ui-core%2Coojs-ui-widgets%2Cvue&skin=vector-2022&version=cnj1r:49:881)
    at process (https://test.wikipedia.org/w/load.php?lang=en&modules=jquery%2Coojs-ui-core%2Coojs-ui-widgets%2Cvue&skin=vector-2022&version=cnj1r:50:544) undefined

Might be unrelated or not worth investigating since it happens after the first exception but pasting it for awareness.

After going through the steps to reproduce once and seeing the described error I'm not longer able to reproduce the error because I get a different one:

jQuery.Deferred exception: Cannot read properties of null (reading 'indexOf') TypeError: Cannot read properties of null (reading 'indexOf')
    at Object.setupTryNewTaskPanel (<anonymous>:5:803)
    at <anonymous>:9:525
    at mightThrow (https://test.wikipedia.org/w/load.php?lang=en&modules=jquery%2Coojs-ui-core%2Coojs-ui-widgets%2Cvue&skin=vector-2022&version=cnj1r:49:881)
    at process (https://test.wikipedia.org/w/load.php?lang=en&modules=jquery%2Coojs-ui-core%2Coojs-ui-widgets%2Cvue&skin=vector-2022&version=cnj1r:50:544) undefined

Might be unrelated or not worth investigating since it happens after the first exception but pasting it for awareness.

That should be fixed by rEGREd38c4566b2de: TryNewTask: Set an array fallback if TryNewTaskOptOuts is null.

Change 900418 had a related patch set uploaded (by Kosta Harlan; author: Kosta Harlan):

[mediawiki/extensions/GrowthExperiments@master] LevelingUpManager: Handle links/link-recommendation collision

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

Change 900418 merged by jenkins-bot:

[mediawiki/extensions/GrowthExperiments@master] LevelingUpManager: Handle links/link-recommendation collision

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

Change 900684 had a related patch set uploaded (by Kosta Harlan; author: Kosta Harlan):

[mediawiki/extensions/GrowthExperiments@wmf/1.40.0-wmf.27] LevelingUpManager: Handle links/link-recommendation collision

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

Change 900684 merged by jenkins-bot:

[mediawiki/extensions/GrowthExperiments@wmf/1.40.0-wmf.27] LevelingUpManager: Handle links/link-recommendation collision

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

Mentioned in SAL (#wikimedia-operations) [2023-03-20T20:47:50Z] <kharlan@deploy2002> Started scap: Backport for [[gerrit:901146|TryNewTask: Set an array fallback if TryNewTaskOptOuts is null]], [[gerrit:900685|PostEdit: Increment the edit-count-for-task-type count (T332319)]], [[gerrit:900684|LevelingUpManager: Handle links/link-recommendation collision (T332309)]]

Mentioned in SAL (#wikimedia-operations) [2023-03-20T20:49:27Z] <kharlan@deploy2002> kharlan: Backport for [[gerrit:901146|TryNewTask: Set an array fallback if TryNewTaskOptOuts is null]], [[gerrit:900685|PostEdit: Increment the edit-count-for-task-type count (T332319)]], [[gerrit:900684|LevelingUpManager: Handle links/link-recommendation collision (T332309)]] synced to the testservers: mwdebug2001.codfw.wmnet, mwdebug2002.codfw.wmnet, mwdebug1001.eqiad.wmnet, mwdebug1002.eqiad.wmn

Mentioned in SAL (#wikimedia-operations) [2023-03-20T20:58:18Z] <kharlan@deploy2002> Finished scap: Backport for [[gerrit:901146|TryNewTask: Set an array fallback if TryNewTaskOptOuts is null]], [[gerrit:900685|PostEdit: Increment the edit-count-for-task-type count (T332319)]], [[gerrit:900684|LevelingUpManager: Handle links/link-recommendation collision (T332309)]] (duration: 10m 28s)

This change is now in wmf.27, so removing from release blockers. cc @Etonkovidova

This change is now in wmf.27, so removing from release blockers. cc @Etonkovidova

Thx, @kostajh! Checked on testwiki wmf.27 (along with T332227) - the issue has been fixed.