atlantis icon indicating copy to clipboard operation
atlantis copied to clipboard

Github update status error is logged with empty URL as if there were misconfiguration

Open maximmasiutin opened this issue 6 months ago • 2 comments

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

GitHub update status error is logged with empty URL as if there were misconfiguration, for example:

{"level":"debug","ts":"2025-05-16T11:41:29.109Z","caller":"vcs/github_client.go:871","msg":"Updating status on GitHub pull request 2421 for '1/1 projects policies checked successfully.' to 'success'","json":{"repo":"mycompany/myrepository","pull":"2421"}}
{"level":"debug","ts":"2025-05-16T11:41:29.186Z","caller":"vcs/github_client.go:881","msg":"POST /repos/mycompany/myrepository/statuses/afa7161234d5643db7e994b6583846b365517fca returned: 404","json":{"repo":"mycompany/myrepository","pull":"2421"}}
{"level":"error","ts":"2025-05-16T11:41:29.186Z","caller":"vcs/instrumented_client.go:221","msg":**"Unable to update status at url: , error: POST https://api.github.com/repos/mycompany/myrepository/statuses/afa7165350d5643db7e994b6583846b365517fca: 404 Not Found []"**,"json":{"repo":"mycompany/myrepository","pull":"2421"},"stacktrace":"github.com/runatlantis/atlantis/server/events/vcs.(*InstrumentedClient).UpdateStatus\n\tgithub.com/runatlantis/atlantis/server/events/vcs/instrumented_client.go:221\ngithub.com/runatlantis/atlantis/server/events/vcs.(*ClientProxy).UpdateStatus\n\tgithub.com/runatlantis/atlantis/server/events/vcs/proxy.go:89\ngithub.com/runatlantis/atlantis/server/events.(*DefaultCommitStatusUpdater).UpdateCombinedCount\n\tgithub.com/runatlantis/atlantis/server/events/commit_status_updater.go:82\ngithub.com/runatlantis/atlantis/server/events.(*ApprovePoliciesCommandRunner).updateCommitStatus\n\tgithub.com/runatlantis/atlantis/server/events/approve_policies_command_runner.go:104\ngithub.com/runatlantis/atlantis/server/events.(*ApprovePoliciesCommandRunner).Run\n\tgithub.com/runatlantis/atlantis/server/events/approve_policies_command_runner.go:89\ngithub.com/runatlantis/atlantis/server/events.(*DefaultCommandRunner).RunCommentCommand\n\tgithub.com/runatlantis/atlantis/server/events/command_runner.go:389"}

Reproduction Steps

Have a GitHub token or a GitHub app that does not have permission to update status on pull requests

Logs

See above the logs ("bold" emphasis mine).

Environment details

This does not depend on the environment, but happens with Github private repos.

Additional Context

Atlantis tries to log an URL, but the URL may be empty by design of the function calls, for example:

func (d *DefaultCommitStatusUpdater) UpdateCombined(logger logging.SimpleLogging, repo models.Repo, pull models.PullRequest, status models.CommitStatus, cmdName command.Name) error {
	src := fmt.Sprintf("%s/%s", d.StatusName, cmdName.String())
	var descripWords string
	switch status {
	case models.PendingCommitStatus:
		descripWords = genProjectStatusDescription(cmdName.String(), "in progress...")
	case models.FailedCommitStatus:
		descripWords = genProjectStatusDescription(cmdName.String(), "failed.")
	case models.SuccessCommitStatus:
		descripWords = genProjectStatusDescription(cmdName.String(), "succeeded.")
	}
	return d.Client.UpdateStatus(logger, repo, pull, status, src, descripWords, "")
}

Conclusion

This bug report details an issue where updating a GitHub pull request’s status in a private repos causing an error misleadingly shows an empty URL.

maximmasiutin avatar May 16 '25 13:05 maximmasiutin

Hello @maximmasiutin! I'm Dosu, a bot here to help you solve bugs, answer questions, and guide you on your journey to becoming a contributor. I'm ready to assist you while you wait for a human maintainer. How can I help you today?

The GitHub update status error with an empty URL occurs because the UpdateStatus function is called with an empty string for the URL parameter in the UpdateCombined method of the DefaultCommitStatusUpdater struct. This is evident in the code snippet:

return d.Client.UpdateStatus(logger, repo, pull, status, src, descripWords, "")

To resolve this issue, ensure that the GitHub token or app used by Atlantis has the necessary permissions to update commit statuses. Specifically, the token or app should have the repo:status permission. Without this permission, the update attempt will fail, resulting in the error being logged [1].

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

dosubot[bot] avatar May 16 '25 13:05 dosubot[bot]

Fixed by #5586

maximmasiutin avatar May 16 '25 13:05 maximmasiutin