-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
--gh-allow-mergeable-bypass-apply
flag will panic if no required checks on GH branch protection settings
#2663
Comments
For what it's worth, I'm running with the same Perhaps there is an Here is the full stack trace if you or others would like to contribute. atlantis/server/events/vcs/github_client.go Lines 307 to 310 in 9cfcd13
atlantis/server/events/vcs/github_client.go Lines 327 to 329 in 9cfcd13
atlantis/server/events/vcs/github_client.go Lines 394 to 398 in 9cfcd13
atlantis/server/events/vcs/proxy.go Line 72 in 9cfcd13
atlantis/server/events/command_runner.go Line 296 in 9cfcd13
|
This was the PR #2470 that implemented this. cc: @stasostrovskyi in case you might be able to see a quick solution for this |
@nikolaik what are the branch protection rules you have that trigger this error? Technically, both We are also running this version for a pretty long time without issues, so would be really interesting to know your setup |
My extremely quick analysis tells me that one possible reason for panic would be to have no required checks in branch protection. But as I said above, this feature expects at least one to exist, otherwise you don't need to use it |
@stasostrovskyi That is probably it! We have a generic setup consumed by a range of repos, and some will be in a state without required checks. In this case, when no checks are required, I guess it would make sense to allow merging then? just an early return in |
Well, probably the logic in this case should be something like that: If there is no Unless someone wants to jump on it, I will try to find some time next week to fix it. |
There is a requiredChecks, _, err := required.GetRequiredStatusChecks(context.Background(), repo.Owner, repo.Name, *pull.Base.Ref) |
AllowMergeableBypassApply
flag--allow-mergeable-bypass-apply
flag will panic if no required checks on GH branch protection settings
--allow-mergeable-bypass-apply
flag will panic if no required checks on GH branch protection settings--allow-mergeable-bypass-apply
flag will panic if no required checks on GH branch protection settings
--allow-mergeable-bypass-apply
flag will panic if no required checks on GH branch protection settings--gh-allow-mergeable-bypass-apply
flag will panic if no required checks on GH branch protection settings
Friendly ping @stasostrovskyi |
Yeah, sorry, life happened :) I've tried to reproduce this issue, both with tests and in the wild and wasn't able to.. @nikolaik can you screenshot/list your protected branches? Is it consistent per repo or happens randomly on the same PR/repo? |
cc @nikolaik friendly ping |
Sorry for not replying sooner! I have not seen this lately, but will try to make reproduction and report back |
I wonder if this is related to : #2979 |
I don't believe it's related to that since PR 2979 was merged in Jan 12 2023 and this issue was created Nov 11 2022. I think this issue stems from assuming there is at least 1 required check when the flag is enabled, instead of checking to see if there are required checks. It's probably an easy fix. I think @nikolaik was reproducing it in order to supply a fix. |
@nikolaik So it happens during the plan now? Can you please add a screenshot of your branch protection settings? I wasn't able to reproduce it myself by just removing all required checks, so there must be something else in play.. Also, does it happen constantly on this PR/repo or does it work fine eventually? |
@stasostrovskyi I enabled the single non-atlantis check to be a required and it started working The Require status checks to pass before merging flag was off completely. Could that be it? |
Just confirmed on two disctinct repos that checking the Require status checks to pass before merging flag works around the panic |
My guess would be that this line atlantis/server/events/vcs/github_client.go Line 431 in 7a33828
just assumes that if branch is protected then it must have required checks set. I think trying to access .Contexts on empty object could result in invalid memory address panic BTW, looks like the Contexts being deprecated |
Community Note
Overview of the Issue
Atlantis v0.20.1 panicked when running
atlantis apply
on a GitHub PR configured withAllowMergeableBypassApply
turned on.Doing another
atlantis apply
a bit later ran successfully. Could something in the responses from github inRepositories.GetBranchProtection
orChecks.ListCheckSuitesForRef
be nil in some cases?Reproduction Steps
AllowMergeableBypassApply
atlantis plan
atlantis apply
The text was updated successfully, but these errors were encountered: