Skip to content
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

Atlantis api/plan returns status 500 #5322

Open
Exchizz opened this issue Feb 13, 2025 · 2 comments · May be fixed by #5323
Open

Atlantis api/plan returns status 500 #5322

Exchizz opened this issue Feb 13, 2025 · 2 comments · May be fixed by #5323
Labels
bug Something isn't working

Comments

@Exchizz
Copy link

Exchizz commented Feb 13, 2025

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

I'm trying to use Atlantis' plan API but it returns 500 and no information about what happened. Atlantis with debug log enabled doesn't reveal anything about what's causing Atlantis to fail.

Reproduction Steps

I'm calling the plan API with the following command:

curl --request POST 'https://<ATLANTIS_HOST_NAME>/api/plan' \
--header 'X-Atlantis-Token: <ATLANTIS_API_SECRET>' \
--header 'Content-Type: application/json' \
--data-raw '{
    "Repository": "repo-name",
    "Ref": "main",
    "Type": "Github",
    "Paths": [{
      "Directory": ".",
      "Workspace": "default"
    }],
}'

Logs

Environment details

Additional Context

I can't get it to work with Atlantis v0.32.0 but it fails with version v0.33.0 and main. I've run atlantis with vs codes's debugger, and it fails when trying to execute the next step:

https://github.com/runatlantis/atlantis/blob/main/server/controllers/api_controller.go#L190

	// Update the combined plan commit status to pending
	if err := a.CommitStatusUpdater.UpdateCombined(ctx.Log, ctx.Pull.BaseRepo, ctx.Pull, models.PendingCommitStatus, command.Plan); err != nil {
		ctx.Log.Warn("unable to update plan commit status: %s", err)
	}

If I comment out the lines above, Atlantis runs the plan successfully. From git blame, the code shown above might be related to this PR: #5242

@Exchizz Exchizz added the bug Something isn't working label Feb 13, 2025
Copy link

dosubot bot commented Feb 13, 2025

Hey @Exchizz, I'm here to help you with any bugs, questions, or contributions!

I found a similar open issue titled API POST requests 500 Internal Server Error, which was last updated on September 29, 2024. However, this issue has no comments or references, so it might not provide additional insights into your problem [1].

Regarding your issue with the api/plan endpoint returning a 500 status code, it seems to be related to the CommitStatusUpdater.UpdateCombined method. This method updates the commit status to "pending" and interacts with external services via the vcs.Client.UpdateStatus method. If this operation fails, it logs a warning but does not provide further details, which could be causing the 500 error [2].

To troubleshoot, ensure that the ctx.Pull.BaseRepo and ctx.Pull values are correctly populated and that the necessary permissions for updating commit statuses are in place. The Atlantis API requires specific permissions depending on the Git host being used. For GitHub, the Atlantis user must have "Write permissions" or be a "Collaborator" to set commit statuses. When using a GitHub App, "Read and write" permissions for commit statuses are needed [3].

Additionally, the issue might be linked to changes introduced in pull request #5242, which could have affected the behavior of the api/plan endpoint. Unfortunately, I couldn't find specific details about the changes in that pull request [4].

To continue talking to Dosu, mention @dosu.


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

@X-Guardian
Copy link
Contributor

Thanks for this @Exchizz. I'm looking at why this wasn't picked up in the tests, and this has exposed lots of other issues with the plan and apply APIs. Be aware that they are really only 'alpha' quality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants