File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -203,6 +203,11 @@ func (cp *CopilotSeatDetails) UnmarshalJSON(data []byte) error {
203
203
cp .PlanType = seatDetail .PlanType
204
204
205
205
switch v := seatDetail .Assignee .(type ) {
206
+ case nil :
207
+ // Assignee can be null according to GitHub API specification.
208
+ // See: https://docs.github.com/en/rest/copilot/copilot-user-management?apiVersion=2022-11-28#list-all-copilot-seat-assignments-for-an-organization
209
+ // Note: Copilot API is in public preview and subject to change.
210
+ cp .Assignee = nil
206
211
case map [string ]any :
207
212
jsonData , err := json .Marshal (seatDetail .Assignee )
208
213
if err != nil {
Original file line number Diff line number Diff line change @@ -58,6 +58,16 @@ func TestCopilotSeatDetails_UnmarshalJSON(t *testing.T) {
58
58
want : & CopilotSeatDetails {},
59
59
wantErr : true ,
60
60
},
61
+ {
62
+ name : "Null Assignee" ,
63
+ data : `{
64
+ "assignee": null
65
+ }` ,
66
+ want : & CopilotSeatDetails {
67
+ Assignee : nil ,
68
+ },
69
+ wantErr : false ,
70
+ },
61
71
{
62
72
name : "Invalid Assignee Field Type" ,
63
73
data : `{
You can’t perform that action at this time.
0 commit comments