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

PANIC: runtime error: invalid memory address or nil pointer dereference #150

Closed
philslab-ninja opened this issue Jun 15, 2018 · 3 comments
Closed

Comments

@philslab-ninja
Copy link

Hi,

I am trying to get atlantis to work using GitLab. I have setup atlantis and gitlab (on-premise as well as gitlab.com) and everything seems to be communicating ok. When I enter "atlantis help" as a comment on a commit I get the following error (tested with atlantis standalone and docker version). Tested with different atlantis versions (latest, v0.3.10, v0.3.9).

Probably I am doing something wrong as I have seen no issue for this so far - but I cannot find the problem.

My docker command (username, Token and Secret are correct - blanked out here):

[root@ip-172-31-24-145 ec2-user]# docker run -p 4141:4141 runatlantis/atlantis:latest server --atlantis-url http://xx.xx.xx.xx:4141 --gitlab-user MyUsername --gitlab-token AValidToken --gitlab-webhook-secret TheGitLabSecret --repo-whitelist *
2018/06/15 13:53:55 [WARN] server: Atlantis started - listening on port 4141
2018/06/15 13:54:05 PANIC: runtime error: invalid memory address or nil pointer dereference
goroutine 20 [running]:
github.com/runatlantis/atlantis/vendor/github.com/urfave/negroni.(*Recovery).ServeHTTP.func1(0x7f13c2ff8010, 0xc4201e2280, 0xc4200e1a40)
	/go/src/github.com/runatlantis/atlantis/vendor/github.com/urfave/negroni/recovery.go:34 +0xef
panic(0x9a1ac0, 0xdf19d0)
	/usr/local/go/src/runtime/panic.go:502 +0x229
github.com/runatlantis/atlantis/server/events.(*EventParser).ParseGitlabMergeCommentEvent(0xc420059e80, 0xc420023a60, 0x4, 0xc420204000, 0x6c2868, 0xc4200217a0, 0x14, 0x0, 0x0, 0x0, ...)
	/go/src/github.com/runatlantis/atlantis/server/events/event_parser.go:172 +0x1f3
github.com/runatlantis/atlantis/server.(*EventsController).HandleGitlabCommentEvent(0xc42018d5f0, 0x7f13c2ff8010, 0xc4201e2280, 0xc420023a60, 0x4, 0xc420204000, 0x6c2868, 0xc4200217a0, 0x14, 0x0, ...)
	/go/src/github.com/runatlantis/atlantis/server/events_controller.go:171 +0xd2
github.com/runatlantis/atlantis/server.(*EventsController).handleGitlabPost(0xc42018d5f0, 0x7f13c2ff8010, 0xc4201e2280, 0xc420107600)
	/go/src/github.com/runatlantis/atlantis/server/events_controller.go:159 +0x32e
github.com/runatlantis/atlantis/server.(*EventsController).Post(0xc42018d5f0, 0x7f13c2ff8010, 0xc4201e2280, 0xc420107600)
	/go/src/github.com/runatlantis/atlantis/server/events_controller.go:70 +0x191
github.com/runatlantis/atlantis/server.(*EventsController).Post-fm(0x7f13c2ff8010, 0xc4201e2280, 0xc420107600)
	/go/src/github.com/runatlantis/atlantis/server/server.go:292 +0x48
net/http.HandlerFunc.ServeHTTP(0xc4201bedf0, 0x7f13c2ff8010, 0xc4201e2280, 0xc420107600)
	/usr/local/go/src/net/http/server.go:1947 +0x44
github.com/runatlantis/atlantis/vendor/github.com/gorilla/mux.(*Router).ServeHTTP(0xc4201b8cb0, 0x7f13c2ff8010, 0xc4201e2280, 0xc420107600)
	/go/src/github.com/runatlantis/atlantis/vendor/github.com/gorilla/mux/mux.go:162 +0xed
github.com/runatlantis/atlantis/vendor/github.com/urfave/negroni.Wrap.func1(0x7f13c2ff8010, 0xc4201e2280, 0xc420107400, 0xc4200e1c40)
	/go/src/github.com/runatlantis/atlantis/vendor/github.com/urfave/negroni/negroni.go:41 +0x4d
github.com/runatlantis/atlantis/vendor/github.com/urfave/negroni.HandlerFunc.ServeHTTP(0xc4200e1ae0, 0x7f13c2ff8010, 0xc4201e2280, 0xc420107400, 0xc4200e1c40)
	/go/src/github.com/runatlantis/atlantis/vendor/github.com/urfave/negroni/negroni.go:24 +0x4e
github.com/runatlantis/atlantis/vendor/github.com/urfave/negroni.middleware.ServeHTTP(0xae7d40, 0xc4200e1ae0, 0xc4200e1b40, 0x7f13c2ff8010, 0xc4201e2280, 0xc420107400)
	/go/src/github.com/runatlantis/atlantis/vendor/github.com/urfave/negroni/negroni.go:33 +0xa5
github.com/runatlantis/atlantis/vendor/github.com/urfave/negroni.(middleware).ServeHTTP-fm(0x7f13c2ff8010, 0xc4201e2280, 0xc420107400)
	/go/src/github.com/runatlantis/atlantis/vendor/github.com/urfave/negroni/negroni.go:33 +0x60
github.com/runatlantis/atlantis/server.(*RequestLogger).ServeHTTP(0xc42000c460, 0x7f13c2ff8010, 0xc4201e2280, 0xc420107400, 0xc4200e1c20)
	/go/src/github.com/runatlantis/atlantis/server/middleware.go:37 +0x62
github.com/runatlantis/atlantis/vendor/github.com/urfave/negroni.middleware.ServeHTTP(0xae6a80, 0xc42000c460, 0xc4200e1b20, 0x7f13c2ff8010, 0xc4201e2280, 0xc420107400)
	/go/src/github.com/runatlantis/atlantis/vendor/github.com/urfave/negroni/negroni.go:33 +0xa5
github.com/runatlantis/atlantis/vendor/github.com/urfave/negroni.(middleware).ServeHTTP-fm(0x7f13c2ff8010, 0xc4201e2280, 0xc420107400)
	/go/src/github.com/runatlantis/atlantis/vendor/github.com/urfave/negroni/negroni.go:33 +0x60
github.com/runatlantis/atlantis/vendor/github.com/urfave/negroni.(*Recovery).ServeHTTP(0xc4200e1a40, 0x7f13c2ff8010, 0xc4201e2280, 0xc420107400, 0xc4200e1c00)
	/go/src/github.com/runatlantis/atlantis/vendor/github.com/urfave/negroni/recovery.go:45 +0x82
github.com/runatlantis/atlantis/vendor/github.com/urfave/negroni.middleware.ServeHTTP(0xae6f20, 0xc4200e1a40, 0xc4200e1b00, 0x7f13c2ff8010, 0xc4201e2280, 0xc420107400)
	/go/src/github.com/runatlantis/atlantis/vendor/github.com/urfave/negroni/negroni.go:33 +0xa5
github.com/runatlantis/atlantis/vendor/github.com/urfave/negroni.(*Negroni).ServeHTTP(0xc4201dc1b0, 0xaeba40, 0xc4201022a0, 0xc420107400)
	/go/src/github.com/runatlantis/atlantis/vendor/github.com/urfave/negroni/negroni.go:73 +0xf2
net/http.serverHandler.ServeHTTP(0xc42018d790, 0xaeba40, 0xc4201022a0, 0xc420107400)
	/usr/local/go/src/net/http/server.go:2694 +0xbc
net/http.(*conn).serve(0xc4201bb900, 0xaebf80, 0xc4201e20c0)
	/usr/local/go/src/net/http/server.go:1830 +0x651
created by net/http.(*Server).Serve
	/usr/local/go/src/net/http/server.go:2795 +0x27b

Thanks for any help!

@lkysow
Copy link
Member

lkysow commented Jun 15, 2018

Hmm, it looks like the API response returned by gitlab doesn't have the field Atlantis expects.
It's looking for MergeRequest.Source.PathWithNamespace: https://github.com/runatlantis/atlantis/blob/master/server/events/event_parser.go#L172

Could you record the webhook that's being sent by GitLab for me? To do this:

  1. Go to https://requestbin.fullcontact.com/ and create a new bin. Copy that URL

  2. Create a new webhook in GitLab with the URL you copied and that receives comment events

  3. Write the Atlantis comment that's causing the above error. If you refresh the requestbin page you should see something like this:
    image

  4. Copy the raw body for me into a comment here or a gist. Or if you'd prefer for privacy send it to luke [at] runatlantis [dot] io

If it's a public repo, you could also send me the URL to it on gitlab.

@philslab-ninja
Copy link
Author

Hi Luke,

oh well - I did not anticipate this only works within a merge request, as soon as I created a branch and submitted a comment on the merge request everything works as expected. Thanks a lot and sorry for bothering you with this!

2018/06/15 17:45:05 [WARN] server: Atlantis started - listening on port 4141
2018/06/15 17:46:49 [INFO] server: 200 | POST /events
2018/06/15 17:47:07 [INFO] server: 200 | POST /events
2018/06/15 17:47:53 [INFO] server: Commenting back on pull request
2018/06/15 17:47:53 [INFO] server: 200 | POST /events
2018/06/15 17:47:53 [INFO] server: 200 | POST /events

@lkysow
Copy link
Member

lkysow commented Jun 16, 2018

Ahh yes, it's only on merge requests. Glad to hear its okay now.

meringu pushed a commit to meringu/atlantis that referenced this issue May 29, 2023
* first draft of the populate function

* Now extra arguments can use environment variables. Fixes runatlantis#146

* now using environment variables while executing terraform commands for variables subsitution

* fix order of terraform command arguments

* Adding single quote around terraform command

* please work this time :)

* fix order for the quote

* fix order for the quote

* Adding single quote around terraform command

* now creating terraform command string to address bash interpolation

* now using 'sh' instead of 'bash' to execute terraform command and added docs about v and env after review
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants