VCS integration - Gitlab webhook gets 401
Hi, I am running a website hosted on my local machine which uses an nginx server as a reverse proxy.
Youtrack is served through a docker container living at http://localhost:8080. The nginx config forwards any requests to https://mydomain.com/track on to the youtrack server. All seems to be working fine.
I'm now trying to set up VCS integration with an external Gitlab account. I've created the app password as per documentation and it says the connection is working. If I click the little button in the VCS integration settings screen to "Import commits and open pull requests", then I get the commit/PR updates displayed on the issue.
However it appears the webhook is not working in Gitlab. When I push commits, I can see no updates to the ticket and requests being rejected in my nginx logs:
[08/Dec/2021:22:35:02 +0000] "POST /track/api/vcsHooksReceiver/gitlab/142-4 HTTP/1.1" 401 68 "-" "GitLab/14.6.0-pre"
[08/Dec/2021:22:35:02 +0000] "POST /track/api/vcsHooksReceiver/gitlab/142-4 HTTP/1.1" 401 68 "-" "GitLab/14.6.0-pre"
[08/Dec/2021:22:35:02 +0000] "POST /track/api/vcsHooksReceiver/gitlab/142-4 HTTP/1.1" 401 68 "-" "GitLab/14.6.0-pre"
[08/Dec/2021:22:35:02 +0000] "POST /track/api/vcsHooksReceiver/gitlab/142-4 HTTP/1.1" 401 68 "-" "GitLab/14.6.0-pre"
This is confirmed when I manually test the webhook in gitlab:
What authorization does this require?
Please sign in to leave a comment.
Gitlab gives the following breakdown:
POST https://mydomain.com/track/api/vcsHooksReceiver/gitlab/142-4
Push Hook
Completed in 0.54 seconds ()
Response
401
Headers
Request
Headers
Hi!
If you didn't omit it intentionally, then there should also be an 'X-Gitlab-Token' header that would serve an authentication purpose, which seems to be the main problem here.
I suggest that you do the following:
If it doesn't help, then please reach out to our support and share the following details:
We'll inspect the data and get back to you with further details. Thanks.
Hi Sergey, thanks for the help disabling and re-enabling added the auth token and now it works!
Strange as I'd deleted and re-made the integration several times, but never disabled/re-enabled.
I've confirmed by resetting all back to normal, creating the integration does not add the auth token. After disabling and re-enabling the auth token is added. A bug?
Hi!
Sorry for the late reply. We've been testing this case and have not reproduced this behavior yet. Creating a new GitLab integration has added a secret token in all the cases. So it might be related to specifics in your GitLab account, which we have no means to verify.
As of now, we added additional logging for hook creation that will be included in one of the upcoming YouTrack releases. After that, we'll keep an eye on related errors to see if we'll be able to identify why such a case may occur. Thanks for bringing it to our attention.
Hi!
Had the exact same problem with Youtrack's in-cloud service as well; testing webhooks on Gitlab also returned 401.
Disabling and re-enabling also fixed the issue.
Some keywords for people to find this:
Cannot see commits in Youtrack VCS changes
VCS Integration does not work
Gitlab CI/CD integration does not work