Skip to content

Send correct value in subscription when a new parent is assigned after clearing old value on work items

Problem

While working on !161013 (merged), there was an observation where the ancestors in the ancestry widget becomes blank while reassigning a parent. This is happening when a current parent is unassigned and a new parent is set from the Parent widget.

Following are the events and response occurring during the steps:

  1. When the parent is unassigned, the workItemUpdate mutation is fired.

  2. Following response is received in workItemUpdated subscription in the hierarchy widget

    {
      "data": {
        "workItemUpdated": {
          ...
          "widgets": [
            ...
            {
              "type": "HIERARCHY",
              "hasParent": false,
              "parent": null,
              "ancestors": {
                "nodes": [],
                "__typename": "WorkItemConnection"
              },
              "__typename": "WorkItemWidgetHierarchy"
            },
            ...
          ],
          "__typename": "WorkItem"
        }
      }
    }
  3. Now, if a new parent is set from the dropdown, workItemUpdate mutation is successfuly fired.

  4. But this time the work item itself is blank like below

    {
      "data": {
        "workItemUpdated": null
      }
    }
  5. Also, if again a parent is set from the dropdown, then we get correct response like below.

    {
      "data": {
        "workItemUpdated": {
          ...
          "widgets": [
            ...
            {
              "type": "HIERARCHY",
              "hasParent": true,
              "parent": {
                "id": "gid://gitlab/WorkItem/1461",
                "__typename": "WorkItem"
              },
              "ancestors": {
                "nodes": [
                  {
                    "id": "gid://gitlab/WorkItem/1461",
                    "iid": "195",
                    "confidential": false,
                    "workItemType": {
                      "id": "gid://gitlab/WorkItems::Type/6",
                      "name": "Objective",
                      "iconName": "issue-type-objective",
                      "__typename": "WorkItemType"
                    },
                    "title": "Objective dups 1",
                    "state": "OPEN",
                    "reference": "gitlab-org/gitlab-test#195",
                    "createdAt": "2024-05-23T08:59:01Z",
                    "closedAt": null,
                    "webUrl": "http://gdk.test:3000/gitlab-org/gitlab-test/-/work_items/195",
                    "widgets": [
                      ...
                    ],
                    "__typename": "WorkItem"
                  }
                ],
                "__typename": "WorkItemConnection"
              },
              "__typename": "WorkItemWidgetHierarchy"
            },
            ...
          ],
          "__typename": "WorkItem"
        }
      }
    }

Screen recording

Screen Recording 2024-07-29 at 6.20.25 PM.mov

Expectation

When the parent is reassigned, the workItemUpdated should have the work item with proper ancestor data.

Steps to reproduce

  1. Visit any work item
  2. Set a parent using Parent widget from the side panel
  3. Clear the value of the parent using Unassign button in the dropdown
  4. Reassign a parent value

To check the subscription data,

  1. Find cable network request after reloading the page
  2. Make sure the WebSocket filter is selected as WS on the top-bar settings
  3. Filter the event using workItemAncestorsUpdated
  4. Check the request which has message field in it
Edited by Rajan Mistry