Skip to content

GitHub API: check repository for null #8733

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kylos101 opened this issue Mar 10, 2022 · 6 comments
Closed

GitHub API: check repository for null #8733

kylos101 opened this issue Mar 10, 2022 · 6 comments
Labels
component: content-service feature: context awareness meta: stale This issue/PR is stale and will be closed soon team: webapp Issue belongs to the WebApp team type: bug Something isn't working

Comments

@kylos101
Copy link
Contributor

Bug description

image

Steps to reproduce

Delete a branch in a PR.
Restore it.
Try opening this using the Gitpod browser extension.

Originally discovered here

Workspace affected

n/a

Expected behavior

Should be able to open Gitpod from a branch which was deleted and is now restored.

Example repository

gitpod-io/workspace-images#564

Anything else?

No response

@kylos101
Copy link
Contributor Author

kylos101 commented Mar 10, 2022

I think it was just taking Github a long time to restore? Works now, ~26 minutes later. That, or we've got some kind of cache on our side that had to be invalidated.

@geropl
Copy link
Member

geropl commented Mar 11, 2022

@AlexTugarev I faintly recall you fixed a similar error in the past? What was it exactly?
@jankeromnes Could this have been re-introduced by the GHE changes? 🤔

@geropl geropl moved this to Needs Design in 🍎 WebApp Team Mar 11, 2022
@jankeromnes
Copy link
Contributor

jankeromnes commented Mar 11, 2022

Interesting, this looks like #3659, which we had fixed with #3869.

I wonder why it came back. Will have a quick look at where we possibly try to read .repository of null.

Also, FYI, I believe this is indeed GitHub taking some time to fully restore a deleted branch.


I wonder if GraphQL calls somehow changed and can now return something like result: { data: null }? 🤔

This could explain why we're trying to read .repository of null in these lines (GitHub Pull Request context parser):

if (result.data.repository === null) {
throw await NotFoundError.create(await this.tokenHelper.getCurrentToken(user), user, this.config.host, owner, repoName);
}
const pr = result.data.repository.pullRequest;

before reaching the line that checks whether the branch was deleted (original fix):

if (pr.headRef === null) {
throw new Error(`Could not open pull request ${owner}/${repoName}#${pullRequestNr}. Source branch may have been removed.`);
}

@jankeromnes
Copy link
Contributor

It's worth changing to check result?.data?.repository for null.

Aha, good idea! 🎯

Also, it seems like GH API doesn't consistently return same in such cases. If you try again on the PR mentioned above, it's reports as expected.

Yes, as @kylos101 reported, this problem was only temporary:

I think it was just taking Github a long time to restore? Works now, ~26 minutes later.

@jldec jldec removed the status in 🍎 WebApp Team Apr 12, 2022
@geropl geropl changed the title Cannot open Gitpod from deleted branch which has been restored GitHub API: check repository for null Apr 14, 2022
@geropl geropl added the type: bug Something isn't working label Apr 14, 2022
@stale
Copy link

stale bot commented Jul 13, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the meta: stale This issue/PR is stale and will be closed soon label Jul 13, 2022
@stale stale bot closed this as completed Aug 13, 2022
@stale stale bot moved this to Done in 🍎 WebApp Team Aug 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: content-service feature: context awareness meta: stale This issue/PR is stale and will be closed soon team: webapp Issue belongs to the WebApp team type: bug Something isn't working
Projects
Archived in project
Development

No branches or pull requests

4 participants