Skip to content

Properly handle the new style of Node IDs in the GitHub GraphQL API - #914

Merged
jcudit merged 2 commits into
integrations:mainfrom
starhawking:add-util-tests
Nov 15, 2021
Merged

jcudit merged 2 commits into
integrations:mainfrom
starhawking:add-util-tests

Conversation

@starhawking

@starhawking starhawking commented Sep 25, 2021 •

Copy link
Copy Markdown
Contributor

@majormoses majormoses left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@majormoses

Copy link
Copy Markdown
Contributor

@jcudit can we get some eyes? This bug is popping up for all new repositories while existing seems to work.

Comment on lines -44 to -48
// Check if the name is a base 64 encoded node ID
_, err := base64.StdEncoding.DecodeString(name)
if err != nil {
return false, nil
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Are there any backwards compatibility risks with removing this? Aiming to read more on this front, but hesitating to merge this without more clarity around if this will be a breaking change for some.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@jcudit That's what I wanted to verify with mocking out the Github API in the unit tests I wrote. I saw in the edit history that every version that accepted a node_id had this local check before calling out to the github api. Originally, it was checking the length. It was checking for base64, but I never saw a version without a pre-check, so it wasn't clear if it was originally put in to address an issue, or if the idea was to simply save an api call.

If you can think of any other cases that'd be worth testing for, I'd be more than happy to add them.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

originally put in to address an issue

Yes, the aim was to allow passing in a repository name to improve the configuration experience. See #593 for details on this.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

c5a7393 suggests we check for both new and old formats. How does everyone feel about this approach? Seems like a 👎🏾 from a performance / rate limiting perspective but 👍🏾 for reliability.

@jcudit jcudit added this to the v4.17.0 milestone Sep 28, 2021
@jcudit jcudit modified the milestones: v4.17.0, v4.18.0 Oct 17, 2021
}

// Interpret `name` as a legacy node ID
exists, _ = repositoryLegacyNodeIDExists(name, meta)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What's the reason the error is ignored here? This function already returns an error, so perhaps it's best to add a condition like the following:

Suggested change
exists, _ = repositoryLegacyNodeIDExists(name, meta)
exists, err = repositoryLegacyNodeIDExists(name, meta)
if err != nil {
return nil, err
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ohhh, I see, it's to continue to check the non-legacy case. Please disregard me! This looks good.

@jcudit jcudit modified the milestones: v4.18.0, v4.19.0 Nov 8, 2021
@jcudit jcudit modified the milestones: v4.19.0, v4.18.1 Nov 15, 2021
@jcudit
jcudit merged commit 705aa70 into integrations:main Nov 15, 2021
kfcampbell pushed a commit to kfcampbell/terraform-provider-github that referenced this pull request Jul 26, 2022
…ntegrations#914)

* Properly handle the new style of Node IDs in the GitHub GraphQL API

https://github.blog/2021-02-10-new-global-id-format-coming-to-graphql/

* fixup! maintain compatibility with deprecated Global ID format

Co-authored-by: Emma May <[email protected]>
Co-authored-by: Jeremy Udit <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants