atlantis: Automerge fails on github free accounts in 0.23.3 due to branch protection api error

Community Note

  • Please vote on this issue by adding a πŸ‘ reaction to the original issue to help the community and maintainers prioritize this request. Searching for pre-existing feature requests helps us consolidate datapoints for identical requirements into a single place, thank you!
  • Please do not leave β€œ+1” or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.

Overview of the Issue

After upgrading from 0.23.2 to 0.23.3, Atlantis is no longer able to automerge PRs. It will perform the apply and even post a comment saying Automatically merging because all plans have been successfully applied., but the PR doesn’t get merged.

Reproduction Steps

  1. Run atlantis on a private repo on a free github account
  2. Submit a pull request
  3. atlantis apply

Logs

Logs
{"level":"info","ts":"2023-03-26T22:04:23.058Z","caller":"events/automerger.go:32","msg":"automerging pull request","json":{"repo":"jescholl/<REDACTED_PRIVATE_REPO>","pull":"162"}}
{"level":"error","ts":"2023-03-26T22:04:23.350Z","caller":"vcs/instrumented_client.go:231","msg":"Unable to merge pull, error: getting branch protection rules: GET https://api.github.com/repos/jescholl/<REDACTED_PRIVATE_REPO>/branches/master/protection: 403 Upgrade to GitHub Pro or make this repository public to enable this feature. []","json":{"pull-num":162},"stacktrace":"...trace below..."}

trace

stacktrace:github.com/runatlantis/atlantis/server/events/vcs.(*InstrumentedClient).MergePull
	github.com/runatlantis/atlantis/server/events/vcs/instrumented_client.go:231
github.com/runatlantis/atlantis/server/events/vcs.(*ClientProxy).MergePull
	github.com/runatlantis/atlantis/server/events/vcs/proxy.go:84
github.com/runatlantis/atlantis/server/events.(*AutoMerger).automerge
	github.com/runatlantis/atlantis/server/events/automerger.go:35
github.com/runatlantis/atlantis/server/events.(*ApplyCommandRunner).Run
	github.com/runatlantis/atlantis/server/events/apply_command_runner.go:183
github.com/runatlantis/atlantis/server/events.(*DefaultCommandRunner).RunCommentCommand
	github.com/runatlantis/atlantis/server/events/command_runner.go:296

Environment details

  • Atlantis version: 0.23.3

Atlantis server-side config file:

# config file
repos:
- id: "/.*/"
  apply_requirements: []
  plan_requirements: []

Repo atlantis.yaml file:

# config file

Additional Context

I thought I may have been able to work around this issue by eliminating the apply_requirements (see above config), but I still get the same behavior and same errors in the logs.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 7
  • Comments: 18 (12 by maintainers)

Most upvoted comments

@jescholl your case is pretty straightforward to me, we need to catch this error as we do for github.ErrBranchNotProtected and continue as usual. I will work on the fix for that.

@nitrocode, I tested as you suggested and it looks like you were right, dev-debian-47f0258 works as expected but dev-debian-7a33828 fails to merge after applying.

The error seems to be

Unable to merge pull, error: getting branch protection rules: GET https://api.github.com/repos/jescholl/<REDACTED_PRIVATE_REPO>/branches/master/protection: 403 Upgrade to GitHub Pro or make this repository public to enable this feature. []

Not sure if this is atlantis related.

If you downgrade back to 0.23.2, does it work as expected?

Yes, downgrading to 0.23.2 resolves the problem.