Skip to content

Conversation

@stephenotalora
Copy link

@stephenotalora stephenotalora commented Oct 27, 2025

BREAKING CHANGES:

  • ProjectV2Field.Options changed from []any to []*ProjectV2FieldOption.
  • Optional fields in various ProjectV2 structs are now passed as pointers

Closes: #3733.

Based on: #3733

Covers all endpoints for project items : https://docs.github.com/en/rest/projects/items?apiVersion=2022-11-28
Adds support to GET fields on project items, specifically the following REST APIs:

@google-cla
Copy link

google-cla bot commented Oct 27, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@stephenotalora
Copy link
Author

Note that you should be able to lint and test locally with ./script/lint.sh and ./script/test.sh.

Thanks! I completely missed the linting errors earlier 🙇🏼

@stephenotalora
Copy link
Author

Working on additional coverage at the moment 👍🏼

@stephenotalora stephenotalora marked this pull request as ready for review October 28, 2025 21:46
@gmlewis
Copy link
Collaborator

gmlewis commented Oct 28, 2025

@stephenotalora - I'm not sure I understand this comment:

It reconciles merge conflicts between upstream/master and the add-project-items branch by synchronizing the branch with the latest master@v76

Also, please change the title of this PR.

@stephenotalora stephenotalora changed the title Stephenotalora/add project items Updates add-project-items branch and adds support for field retrieval Oct 28, 2025
@stephenotalora stephenotalora changed the title Updates add-project-items branch and adds support for field retrieval Updates add-project-items branch with master and implements field retrieval support Oct 28, 2025
@stephenotalora stephenotalora changed the title Updates add-project-items branch with master and implements field retrieval support Updates add-project-items branch with master and adds field retrieval support Oct 28, 2025
@gmlewis gmlewis added NeedsReview PR is awaiting a review before merging. Breaking API Change PR will require a bump to the major version num in next release. Look here to see the change(s). labels Oct 28, 2025
@stephenotalora
Copy link
Author

@stephenotalora - I'm not sure I understand this comment:

It reconciles merge conflicts between upstream/master and the add-project-items branch by synchronizing the branch with the latest master@v76

Also, please change the title of this PR.

Thanks @gmlewis, updated the PR title and PR description, hoping that's a little more clear, let me know if you have any questions.

@gmlewis
Copy link
Collaborator

gmlewis commented Oct 28, 2025

Thanks @gmlewis, updated the PR title and PR description, hoping that's a little more clear, let me know if you have any questions.

So the state of the external-to-this-repo branch called "JoannaaKL:stephenotalora/add-project-items" is irrelevant to this PR and all that information in the description and in the PR title should be removed.

We try to make the PR title helpful to understand what this PR is all about.

How about this:

"feat!: Add methods to edit ProjectsV2 fields"

The "feat!:" part is needed because this PR breaks the API from previous versions.

@stephenotalora stephenotalora changed the title Updates add-project-items branch with master and adds field retrieval support Feat!: Add methods to GET ProjectsV2 fields Oct 28, 2025
@gmlewis gmlewis changed the title Feat!: Add methods to GET ProjectsV2 fields feat!: Add methods to GET ProjectsV2 fields Oct 28, 2025
Copy link
Collaborator

@gmlewis gmlewis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your PR title now says "GET" but this PR also includes "POST", "PATCH", and "DELETE" methods, so please make the PR title reflect this.

Before I proceed with this PR review, it looks like this PR has some regressions that were already addressed in #3718.

UpdatedAt *Timestamp `json:"updated_at,omitempty"`
DeletedAt *Timestamp `json:"deleted_at,omitempty"`
Number *int `json:"number,omitempty"`
Number *int64 `json:"number,omitempty"`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was a discussion about this field being of type int because we felt that a project number would not overflow a 32-bit integer.

Why are you changing this here?

Copy link
Author

@stephenotalora stephenotalora Oct 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you changing this here?

Thanks @gmlewis, I appreciate you resurfacing the previous discussion; I had missed that context earlier. A couple of points that led to this change:

  1. I took over the base PR, at first glance it appeared there was an intentional effort to transition the projectNumber field to an int64.
  2. To validate the assumption:
    • I checked our internal database schema and found the field defined as an UNSIGNED BIGINT
    • Additionally, the OpenAPI specification lists this field as an int64
    • Both of which reinforced the idea that a wider numeric type might be appropriate in Go.

On second thought, though, an UNSIGNED BIGINT doesn’t directly map to a Go int64, since their ranges differ, while a uint64 would technically align more closely, as you described here that would likely add unnecessary complexity given the low risk of overflow for project numbers.

With that in mind, retaining the int type seems appropriate given the prior context. I can update the PR accordingly 👍🏼

updated: fixed in 25561d3

Color string `json:"color,omitempty"`
// An optional description for this option.
Description string `json:"description,omitempty"`
ID *int64 `json:"id,omitempty"` // The unique identifier for this option.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this being changed from a string?
Actually, it should probably be a *string here if it truly is an optional field.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed a string as per our API docs - updated in 27dd1c4

Comment on lines 83 to 85
Name string `json:"name,omitempty"` // The display name of the option.
Color string `json:"color,omitempty"` // The color associated with this option (e.g., "blue", "red").
Description string `json:"description,omitempty"` // An optional description for this option.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional fields should be pointers to strings in general. I'm not sure why these were left as values in #3718.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in 27dd1c4

//
//meta:operation GET /orgs/{org}/projectsV2/{project_number}
func (s *ProjectsService) GetProjectForOrg(ctx context.Context, org string, projectNumber int) (*ProjectV2, *Response, error) {
func (s *ProjectsService) GetProjectForOrg(ctx context.Context, org string, projectNumber int64) (*ProjectV2, *Response, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here and below, projectNumber should remain as int unless you have a good reason to change them in this PR.

Copy link
Author

@stephenotalora stephenotalora Oct 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

based on this comment - fixed in 25561d3

@stephenotalora
Copy link
Author

stephenotalora commented Oct 29, 2025

Your PR title now says "GET" but this PR also includes "POST", "PATCH", and "DELETE" methods, so please make the PR title reflect this.

Yes, thank you 🙇🏼 I went through a rather large conflict earlier, and the title reflected the later additions, that’s my oversight. I’ll update accordingly.

update: I've taken the PR back to a draft while I work on edits.
update-2: @gmlewis PR is ready for another pass, thanks for taking the time to review is much appreciated 🙇🏼

@stephenotalora stephenotalora changed the title feat!: Add methods to GET ProjectsV2 fields feat!: Additional support for project items and fields CRUD operations Oct 29, 2025
@stephenotalora stephenotalora marked this pull request as draft October 29, 2025 18:43
@stephenotalora stephenotalora changed the title feat!: Additional support for project items and fields CRUD operations feat!: Add support for project items CRUD and project fields read operations Oct 29, 2025
@stephenotalora stephenotalora marked this pull request as ready for review October 29, 2025 21:18
Copy link
Collaborator

@gmlewis gmlewis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @stephenotalora.

// GitHub API docs: https://docs.github.com/rest/projects/fields#list-project-fields-for-user
//
//meta:operation GET /users/{username}/projectsV2/{project_number}/fields
func (s *ProjectsService) ListProjectFieldsForUser(ctx context.Context, user string, projectNumber int, opts *ListProjectsOptions) ([]*ProjectV2Field, *Response, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I seem to recall a conversation we had earlier about changing "*ForUser" to (for example) "ListUserProjectFields" but looking through this go-github repo, I see we have both styles and I can't seem to find the conversation, so I'll leave this now and maybe our other reviewers will have an opinion.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to make this change if there’s a strong preference either way. It would be a breaking change on our end, but easy enough to address. I did a quick search across the repo, and it looks like *ForUser and *ForOrg are used fairly extensively, in about 4 and 12 files, respectively.

// GitHub API docs: https://docs.github.com/rest/projects/fields#get-project-field-for-organization
//
//meta:operation GET /orgs/{org}/projectsV2/{project_number}/fields/{field_id}
func (s *ProjectsService) GetProjectFieldForOrg(ctx context.Context, org string, projectNumber, fieldID int64) (*ProjectV2Field, *Response, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

projectNumber should always be int throughout.

Suggested change
func (s *ProjectsService) GetProjectFieldForOrg(ctx context.Context, org string, projectNumber, fieldID int64) (*ProjectV2Field, *Response, error) {
func (s *ProjectsService) GetProjectFieldForOrg(ctx context.Context, org string, projectNumber int, fieldID int64) (*ProjectV2Field, *Response, error) {

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yikes, apologies for missing these 😮‍💨 I've updated all of these similar occurrences under eac21dc

Comment on lines 94 to 97
NodeID string `json:"node_id,omitempty"`
Name string `json:"name,omitempty"`
DataType string `json:"dataType,omitempty"`
URL string `json:"url,omitempty"`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know you didn't write these, but optional fields should be reference types.

Copy link
Author

@stephenotalora stephenotalora Oct 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching these @gmlewis I've updated all in a similar state in 31e34f0 and 032e591

Copy link
Collaborator

@gmlewis gmlewis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @stephenotalora!
LGTM.
Awaiting second LGTM+Approval from any other contributor to this repo before merging.

cc: @stevehipwell - @alexandear - @zyfy29

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Breaking API Change PR will require a bump to the major version num in next release. Look here to see the change(s). NeedsReview PR is awaiting a review before merging.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants