-
-
Notifications
You must be signed in to change notification settings - Fork 491
Fix GitHub API not providing details for existing PRs in private repos #4064
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
base: main
Are you sure you want to change the base?
Conversation
@@ -119,10 +119,39 @@ export class GitHubHelper { | |||
head: headBranch, | |||
base: inputs.base | |||
}) | |||
let existingPullNumber: number | undefined = undefined | |||
if (pulls?.length === 0 || pulls === null || pulls === undefined) { | |||
core.error( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used error
here just so I could find it easier during testing, but should I change this to info
or warning
instead?
Interesting. Thank you for looking into this. First of all, please confirm what version of this action you are using.
This is not happening on private repos on Please provide as much detail as you can about your testing setup. |
Using the latest version of the action with This is on GitHub-hosted cloud enterprise. I tested the API using curl commands directly, on a new repo that only had 2 pull requests (one closed and one open) Starting from a query without any parameters, I was able to confirm that a single element was in the response array, and the value in
Then tried only adding the
|
@obnyis I now understand why this happens. It's a bug that affects the list endpoint when called on forks with the same owner as the repository parent. This has occurred since the ability to fork a repository to the same organization as its parent was added. I can see that there is already an internal issue tracking this bug. I'm now going to see if I can reproduce it in my test suite so I have a way to track this behaviour. |
@peter-evans Thanks for looking into that, and confirming the bug is on forks only. I've changed my own tests and workflows to prevent the action running on forks, and confirmed that it works correctly when running on the source repo. I'll leave it up to you for when you want to close this PR, or if you want me to keep it open and refactor any part of it. |
This should hopefully fix #3742 - tested on a private enterprise repo
I did some testing to discover why this was failing, and found that the "List pull requests" endpoint always returns an empty array if run against an enterprise owned repo when the
head
query is set - I asume this also applies to other private repos.