Verified Commit 859fb26f authored by Florian Forster's avatar Florian Forster
Browse files

fix(workitems): Handle absent status widget in `WorkItem`.

The status widget is not present on all work item types. When the GraphQL API
returns null for the widget, the Go JSON package cannot unmarshal it into a
non-pointer struct, leaving the field zeroed rather than correctly representing
absence. Make the widget and its nested status object pointer types, and change
WorkItem.Status from `string` to `*string` to distinguish "no status widget"
from an empty status name.
parent 6df4a262
Loading
Loading
Loading
Loading
Loading
+11 −5
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ type WorkItem struct {
	IID         int64
	Type        string
	State       string
	Status      string
	Status      *string
	Title       string
	Description string
	CreatedAt   *time.Time
@@ -424,12 +424,18 @@ func (w workItemGQL) unwrap() *WorkItem {
		assignees = append(assignees, a.unwrap())
	}

	var status *string

	if w.Features.Status != nil && w.Features.Status.Status != nil {
		status = w.Features.Status.Status.Name
	}

	return &WorkItem{
		ID:          w.ID.Int64,
		IID:         int64(w.IID),
		Type:        w.WorkItemType.Name,
		State:       w.State,
		Status:      w.Features.Status.Status.Name,
		Status:      status,
		Title:       w.Title,
		Description: w.Description,
		CreatedAt:   w.CreatedAt,
@@ -447,9 +453,9 @@ type workItemFeaturesGQL struct {
			Nodes []userCoreBasicGQL `json:"nodes"`
		} `json:"assignees"`
	} `json:"assignees"`
	Status struct {
		Status struct {
			Name string
	Status *struct {
		Status *struct {
			Name *string
		}
	}
}
+1 −1
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@ func TestGetWorkItem(t *testing.T) {
				IID:         756,
				Type:        "Task",
				State:       "OPEN",
				Status:      "New",
				Status:      Ptr("New"),
				Title:       "Update Helm charts to use Argo Rollouts for progressive deployments",
				Description: "## Overview\n\nUpdate Runway Helm charts to generate Argo Rollout resources ...",
				CreatedAt:   Ptr(time.Date(2026, time.January, 6, 15, 9, 24, 0, time.UTC)),