refactor!: Rename EditComment to UpdateComment on IssuesService, and pass a new IssueCommentRequest by value - #4444
Conversation
…, and pass a new `IssueCommentRequest` by value CreateComment and EditComment reused the 11-field IssueComment response type as their request bodies, but both endpoints accept exactly one parameter, body, and it is required in both schemas. EditComment's doc comment even had to warn "A non-nil comment.Body must be provided. Other comment fields should be left nil" — the new shared IssueCommentRequest makes that warning unnecessary by construction. Since the create and update schemas are identical, a single shared request type is used rather than a split. EditComment is renamed to UpdateComment to match the docs operation name. The IssueComment response type stays unchanged, and its entry is removed from the .golangci.yml allowlist. BREAKING CHANGE: IssuesService.CreateComment now takes a new IssueCommentRequest (with non-pointer Body) by value, and IssuesService.EditComment is renamed to UpdateComment and takes the same IssueCommentRequest by value, instead of *IssueComment.
|
Congratulations, @JamBalaya56562 on PR #4444 !!! 😂 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #4444 +/- ##
=======================================
Coverage 97.55% 97.55%
=======================================
Files 194 194
Lines 19892 19892
=======================================
Hits 19406 19406
Misses 268 268
Partials 218 218 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
gmlewis
left a comment
There was a problem hiding this comment.
Thank you, @JamBalaya56562!
LGTM.
Awaiting second LGTM+Approval from any other contributor to the repo before merging.
Not-Dhananjay-Mishra
left a comment
There was a problem hiding this comment.
Let's also update IssueComment struct.
// IssueComment represents a comment left on an issue.
type IssueComment struct {
ID *int64 `json:"id,omitempty"`
NodeID *string `json:"node_id,omitempty"`
Body *string `json:"body,omitempty"`
User *User `json:"user,omitempty"`
Reactions *Reactions `json:"reactions,omitempty"`
CreatedAt *Timestamp `json:"created_at,omitempty"`
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
// AuthorAssociation is the comment author's relationship to the issue's repository.
// Possible values are "COLLABORATOR", "CONTRIBUTOR", "FIRST_TIMER", "FIRST_TIME_CONTRIBUTOR", "MEMBER", "OWNER", or "NONE".
//
// Deprecated: GitHub will remove this field from Events API payloads on October 7, 2025.
// Use the Issue Comments REST API endpoint to retrieve this information.
// See: https://docs.github.com/rest/issues/comments?apiVersion=2022-11-28#get-an-issue-comment
AuthorAssociation *string `json:"author_association,omitempty"`
URL *string `json:"url,omitempty"`
HTMLURL *string `json:"html_url,omitempty"`
IssueURL *string `json:"issue_url,omitempty"`
}It has few missing fields - performed_via_github_app, pin and minimized
https://docs.github.com/en/rest/issues/comments?apiVersion=2022-11-28#update-an-issue-comment
…ment` The issue-comment response schema includes performed_via_github_app, pin and minimized, which were missing from the Go struct. pin and minimized are modeled with the new PinnedIssueComment and MinimizedIssueComment types matching their schemas.
Thanks @Not-Dhananjay-Mishra — added in 96e0bc1. I verified all three against the issue-comment response schema:
All three are nullable in the response, so they're pointers with |
Continues the request-body-by-value work in #3644, this time for the issue comment endpoints on
IssuesService.CreateCommentandEditCommentreused the 11-fieldIssueCommentresponse type as their request bodies, but per the docs both endpoints accept exactly one parameter,body, and it's required in both. The other ten fields (id,user,reactions,created_at, …) are server-generated. The clearest evidence is in the code itself —EditComment's doc comment had to warn:The new request type makes that warning unnecessary by construction:
Unlike the milestone split in #4438, the create and update schemas here are identical, so a single shared request type is used rather than a create/update pair (same reasoning as
HookConfigin #4360).Bodyis a non-pointerstringsince it's required in both operations.EditCommentis renamed toUpdateCommentto match the docs operation name, Update an issue comment (same convention as #4438/#4400). Both methods now take the body by value, andIssueCommentis removed from thebody-allowed-pointer-typesallowlist. TheIssueCommentresponse type itself is unchanged.Verified with
go build ./...,go vet -tags integration ./test/integration/,gofmt, the full./github/test suite (both methods and the generatedGetBodyat 100%), andcustom-gcl(noparamcheckfindings after removing the allowlist entry).Updates #3644
BREAKING CHANGE: IssuesService.CreateComment now takes a new IssueCommentRequest (with non-pointer Body) by value, and IssuesService.EditComment is renamed to UpdateComment and takes the same IssueCommentRequest by value, instead of *IssueComment.
cc @jvm986 — second item in the
Issuesservice; as before, happy to coordinate whenever you resume.