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

If github custom property is applied on a repo, atlantis stops working. #4989

Open
faizan002 opened this issue Oct 8, 2024 · 9 comments
Open
Labels
bug Something isn't working provider/github

Comments

@faizan002
Copy link

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

We have an Atlantis running as docker container.
It works fine with our github.com/org but as soon as we create a custom property, it stops working.
The webhook shows 200 OK but on atlantis logs, we do not see anything happening. Neither there is an response on PR.

Is it a limitation on atlantis to not being able to interpret webhook when it contains custom_properties ?
Can we enable some logging to see what is happening when atlantis is not able to interepret webhook.

Reproduction Steps

  1. Create a repo in github
  2. Create a Personal access token
  3. Apply custom property on the repo
  4. Start Atlantis in a docker container
  5. Create a Pull request and type atlantis plan

Logs

Environment details

Additional Context

@faizan002 faizan002 added the bug Something isn't working label Oct 8, 2024
Copy link

dosubot bot commented Oct 8, 2024

Hey @faizan002 👋, I'm here to help you with any bugs, questions, or contributions you have. Let's work together to solve this issue!

Atlantis might not handle GitHub webhooks with custom properties effectively, as there is no specific mention of handling custom properties in the available information. This could be causing the issue you're experiencing.

To debug this, you can enable more detailed logging in Atlantis. While specific logging options weren't found in the available data, you can generally increase verbosity by configuring the logging level in your Atlantis setup. Check your Atlantis configuration for any logging settings that can be adjusted to provide more insight into webhook processing.

Additionally, ensure that your webhook secret and repository allowlist are correctly configured, as these are crucial for authenticating and authorizing webhook requests [1][2][3].

To continue talking to Dosu, mention @dosu.

@stasostrovskyi
Copy link
Contributor

Hi @faizan002! Long time, no see :) We have several custom properties, both required and not on all of our repos and we haven't seen any issues with this. Can you check the logs and see if there are any errors?

@faizan002
Copy link
Author

Hi @stasostrovskyi What a pleasant surprise.
I enabled debug logs on Atlantis and a comment "atlantis plan" on my PR.
When I have a custom property "myRandomProperty=temp", Atlantis recieves the webhook, sends 200 OK but it does not do anything on command. Here is the printout.
{"level":"debug","ts":"2024-10-09T07:21:43.067Z","caller":"server/middleware.go:45","msg":"POST /events – from 172.17.0.1:34958","json":{}} {"level":"debug","ts":"2024-10-09T07:21:43.067Z","caller":"events/events_controller.go:119","msg":"handling GitHub post","json":{}} {"level":"debug","ts":"2024-10-09T07:21:43.067Z","caller":"events/events_controller.go:185","msg":"request valid","json":{"gh-request-id":"X-Github-Delivery=nnnnnnn-nnnn-nnnn-nnnn-nnnnnnnnn"}} {"level":"debug","ts":"2024-10-09T07:21:43.069Z","caller":"server/middleware.go:72","msg":"POST /events – respond HTTP 200","json":{}}

Then I removed the property and issued the same comment on PR. Atlantis did accept it as a command.
{"level":"debug","ts":"2024-10-09T07:38:51.518Z","caller":"server/middleware.go:45","msg":"POST /events – from 172.17.0.1:45932","json":{}} {"level":"debug","ts":"2024-10-09T07:38:51.518Z","caller":"events/events_controller.go:119","msg":"handling GitHub post","json":{}} {"level":"debug","ts":"2024-10-09T07:38:51.518Z","caller":"events/events_controller.go:185","msg":"request valid","json":{"gh-request-id":"X-Github-Delivery=nnnnnnn-nnnn-nnnn-nnnn-nnnnnnnnn"}}

{"level":"info","ts":"2024-10-09T07:38:51.518Z","caller":"events/events_controller.go:656","msg":"parsed comment as command=\"plan\" verbose=false dir=\"\" workspace=\"\" project=\"\" policyset=\"\", clear-policy-approval=false, flags=\"\"","json":{"gh-request-id":"X-Github-Delivery=nnnnnnn-nnnn-nnnn-nnnn-nnnnnnnnn","repo":"myorg/myrepo","pull":1}} and so on..

@stasostrovskyi
Copy link
Contributor

I'm 99% sure that there is nothing special in atlantis code with regards to github's custom properties. We are using custom properties (but only single_select ones) and atlantis (latest release) works fine. Are you using latest version (0.30.0)? Do you have any special flags enabled?

@faizan002
Copy link
Author

I do not disagree to what you said and it does not make any sense to me either. I did a diff of working and not-working github-webhook json and this was the difference.
This worked:

"custom_properties": {

    }

and this did not work:

"custom_properties": {
      "tmp-property": [
        "tmp"
      ]
    }

To answer your question:
I tried a vanila setup.

docker run -d \
  --name atlantis \
  -p 4141:4141 \
  -e ATLANTIS_GH_USER=myuser \
  -e ATLANTIS_GH_TOKEN=my_pat \
  -e ATLANTIS_REPO_ALLOWLIST=github.com/myorg/* \
  -e ATLANTIS_LOG_LEVEL=debug \
  ghcr.io/runatlantis/atlantis:latest

@stasostrovskyi
Copy link
Contributor

It's weird :( I think the only way forward is to try and debug atlantis, reproduce the problem and see why it works the way it works..

@faizan002
Copy link
Author

faizan002 commented Oct 15, 2024

it is weirder than that.

We found out that problem occurs if you choose "multi select" type while creating a custom property, We changed it to single select and it worked.

@stasostrovskyi
Copy link
Contributor

That's a good finding! it can as well be down to some tiny bug in https://github.com/google/go-github/blob/master/github/messages.go#L319 as well as in atlantis itself..

@philwitty
Copy link

I checked and this was fixed in https://github.com/google/go-github/releases/tag/v64.0.0 however atlantis wasn't bumped to this version until 2 weeks ago after the latest release

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

No branches or pull requests

3 participants