Repository: google/go-github
Pull request #3567 (2025-04-30 08:01:35)

Add issue `Type` to `IssueRequest`
With he new field for Issue Type, we can also update that field in the edit method, adding that to be able to use it.
updating the tests to add that as well

https://docs.github.com/en/rest/issues/issues?apiVersion=2022-11-28#update-an-issue

cc @gmlewis 

gmlewis: Thank you, @cpanato. Please run step 4 of CONTRIBUTING.md and push the changes to this PR.
codecov[bot]: ## [Codecov](https://app.codecov.io/gh/google/go-github/pull/3567?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 91.24%. Comparing base [(`6a7684f`)](https://app.codecov.io/gh/google/go-github/commit/6a7684f2c5dd43b2bc782a4ee5349eb49aef6584?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) to head [(`5ff88b2`)](https://app.codecov.io/gh/google/go-github/commit/5ff88b2de9503891bfa07fe56213cb6503d772c5?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google).
> Report is 6 commits behind head on master.

<details><summary>Additional details and impacted files</summary>


```diff
@@            Coverage Diff             @@
##           master    #3567      +/-   ##
==========================================
+ Coverage   91.23%   91.24%   +0.01%     
==========================================
  Files         183      183              
  Lines       16053    16075      +22     
==========================================
+ Hits        14646    14668      +22     
  Misses       1231     1231              
  Partials      176      176              
```

</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/google/go-github/pull/3567?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google).

<details><summary> :rocket: New features to boost your workflow: </summary>

- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
</details>
cpanato: > Thank you, @cpanato. Please run step 4 of CONTRIBUTING.md and push the changes to this PR.

sorry @gmlewis forgot to run those, pushed the changes after running the scripts

Patch:
diff --git a/github/github-accessors.go b/github/github-accessors.go
index b2f8b5f0..6378b40b 100644
--- a/github/github-accessors.go
+++ b/github/github-accessors.go
@@ -12406,6 +12406,14 @@ func (i *IssueRequest) GetTitle() string {
 	return *i.Title
 }
 
+// GetType returns the Type field if it's non-nil, zero value otherwise.
+func (i *IssueRequest) GetType() string {
+	if i == nil || i.Type == nil {
+		return ""
+	}
+	return *i.Type
+}
+
 // GetAction returns the Action field if it's non-nil, zero value otherwise.
 func (i *IssuesEvent) GetAction() string {
 	if i == nil || i.Action == nil {
diff --git a/github/issues.go b/github/issues.go
index 6d3a6b15..61a85820 100644
--- a/github/issues.go
+++ b/github/issues.go
@@ -90,6 +90,7 @@ type IssueRequest struct {
 	StateReason *string   `json:"state_reason,omitempty"`
 	Milestone   *int      `json:"milestone,omitempty"`
 	Assignees   *[]string `json:"assignees,omitempty"`
+	Type        *string   `json:"type,omitempty"`
 }
 
 // IssueListOptions specifies the optional parameters to the IssuesService.List


Test patch:
diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go
index a6a75ae0..3588b790 100644
--- a/github/github-accessors_test.go
+++ b/github/github-accessors_test.go
@@ -16064,6 +16064,17 @@ func TestIssueRequest_GetTitle(tt *testing.T) {
 	i.GetTitle()
 }
 
+func TestIssueRequest_GetType(tt *testing.T) {
+	tt.Parallel()
+	var zeroValue string
+	i := &IssueRequest{Type: &zeroValue}
+	i.GetType()
+	i = &IssueRequest{}
+	i.GetType()
+	i = nil
+	i.GetType()
+}
+
 func TestIssuesEvent_GetAction(tt *testing.T) {
 	tt.Parallel()
 	var zeroValue string
diff --git a/github/issues_test.go b/github/issues_test.go
index 4ac67981..28cf28d4 100644
--- a/github/issues_test.go
+++ b/github/issues_test.go
@@ -314,7 +314,7 @@ func TestIssuesService_Edit(t *testing.T) {
 	t.Parallel()
 	client, mux, _ := setup(t)
 
-	input := &IssueRequest{Title: Ptr("t")}
+	input := &IssueRequest{Title: Ptr("t"), Type: Ptr("bug")}
 
 	mux.HandleFunc("/repos/o/r/issues/1", func(w http.ResponseWriter, r *http.Request) {
 		v := new(IssueRequest)
@@ -325,7 +325,7 @@ func TestIssuesService_Edit(t *testing.T) {
 			t.Errorf("Request body = %+v, want %+v", v, input)
 		}
 
-		fmt.Fprint(w, `{"number":1}`)
+		fmt.Fprint(w, `{"number":1, "type": {"name": "bug"}}`)
 	})
 
 	ctx := context.Background()
@@ -334,7 +334,7 @@ func TestIssuesService_Edit(t *testing.T) {
 		t.Errorf("Issues.Edit returned error: %v", err)
 	}
 
-	want := &Issue{Number: Ptr(1)}
+	want := &Issue{Number: Ptr(1), Type: &IssueType{Name: Ptr("bug")}}
 	if !cmp.Equal(issue, want) {
 		t.Errorf("Issues.Edit returned %+v, want %+v", issue, want)
 	}
@@ -529,6 +529,7 @@ func TestIssueRequest_Marshal(t *testing.T) {
 		State:     Ptr("url"),
 		Milestone: Ptr(1),
 		Assignees: &[]string{"a"},
+		Type:      Ptr("issue_type"),
 	}
 
 	want := `{
@@ -542,7 +543,8 @@ func TestIssueRequest_Marshal(t *testing.T) {
 		"milestone": 1,
 		"assignees": [
 			"a"
-		]
+		],
+		"type": "issue_type"
 	}`
 
 	testJSONMarshal(t, u, want)
@@ -582,6 +584,7 @@ func TestIssue_Marshal(t *testing.T) {
 		NodeID:            Ptr("nid"),
 		TextMatches:       []*TextMatch{{ObjectURL: Ptr("ourl")}},
 		ActiveLockReason:  Ptr("alr"),
+		Type:              &IssueType{Name: Ptr("bug")},
 	}
 
 	want := `{
@@ -639,7 +642,10 @@ func TestIssue_Marshal(t *testing.T) {
 				"object_url": "ourl"
 			}
 		],
-		"active_lock_reason": "alr"
+		"active_lock_reason": "alr",
+		"type": {
+			"name": "bug"
+		}
 	}`
 
 	testJSONMarshal(t, u, want)