diff --git a/github/copilot.go b/github/copilot.go index bed83536b41..b4f21ad39aa 100644 --- a/github/copilot.go +++ b/github/copilot.go @@ -203,6 +203,11 @@ func (cp *CopilotSeatDetails) UnmarshalJSON(data []byte) error { cp.PlanType = seatDetail.PlanType switch v := seatDetail.Assignee.(type) { + case nil: + // Assignee can be null according to GitHub API specification. + // See: https://docs.github.com/en/rest/copilot/copilot-user-management?apiVersion=2022-11-28#list-all-copilot-seat-assignments-for-an-organization + // Note: Copilot API is in public preview and subject to change. + cp.Assignee = nil case map[string]any: jsonData, err := json.Marshal(seatDetail.Assignee) if err != nil { diff --git a/github/copilot_test.go b/github/copilot_test.go index ed81761370e..1aeb4308555 100644 --- a/github/copilot_test.go +++ b/github/copilot_test.go @@ -58,6 +58,16 @@ func TestCopilotSeatDetails_UnmarshalJSON(t *testing.T) { want: &CopilotSeatDetails{}, wantErr: true, }, + { + name: "Null Assignee", + data: `{ + "assignee": null + }`, + want: &CopilotSeatDetails{ + Assignee: nil, + }, + wantErr: false, + }, { name: "Invalid Assignee Field Type", data: `{