Gitlab VCS integration with 422 error. wrong username ?

This may be yet another vcs integration problem with gitlab. I guess there's something different from other posts.

What happened was

Received the following error when creating a hook: HTTP 422 Unprocessable Entity The most probable reason is described

 

in VCS integration configuration. I tried with a wrong token and got 401 error. Therefore, the configuration parameters looks good. The gitlab is 14.8.6-ee and youtrack is 2022.1.46592. Both of which are based on  docker images. In the youtrack, -Djetbrains.youtrack.webHooksBaseUrl=http://host02.mydomain.net/youtrack is added in youtrack.jvmoptions (and found in output of `ps auxww`).

In the gitlab side, following log appeared in /var/log/gitlab/gitlab-rails/production.log

Started GET "/api/v4/geo/proxy" for 127.0.0.1 at 2022-05-04 09:51:34 +0000
Started GET "/api/v4/users?username=spike" for 192.168.1.2 at 2022-05-04 09:51:34 +0000
Started GET "/api/v4/projects?search=[FILTERED]&simple=true&per_page=100&membership=true" for 192.168.1.2 at 2022-05-04 09:51:34 +0000
Started POST "/api/v4/projects/2/hooks" for 192.168.1.2 at 2022-05-04 09:51:35 +0000

where 192.168.1.2 is IPv4 of the host youtrack is running, whose fqdn is host02.mydomain.net. The git repository url is http://gitlab.mydomain.net/spike/test00.git where "spike" is group name and is not user's name. According to the production.log, access of youtrack may be recognized by gitlab in a wrong way.

I hope to find a way to solve this problem.

 

Following is dump of tcp packets between youtrack and gitlab after "Save" button of New VCS Integration screen is clicked. 192.168.1.30 is IPv4 address of gitlab.mydomain.net on which gitlab is running.

---------------------------------------------------------------------------------------------------------------

2022-05-04 18:30:35.417408 IP (tos 0x0, ttl 62, id 40093, offset 0, flags [DF], proto TCP (6), length 60)
    192.168.1.2.48550 > 192.168.1.30.80: Flags [S], cksum 0x8704 (correct), seq 1983302754, win 64240, options [mss 1460,sackOK,TS val 1964264950 ecr 0,nop,wscale 7], length 0
2022-05-04 18:30:35.417549 IP (tos 0x0, ttl 63, id 0, offset 0, flags [DF], proto TCP (6), length 60)
    192.168.1.30.80 > 192.168.1.2.48550: Flags [S.], cksum 0x029f (incorrect -> 0x99f0), seq 3293199517, ack 1983302755, win 28960, options [mss 1460,sackOK,TS val 557470897 ecr 1964264950,nop,wscale 7], length 0
2022-05-04 18:30:35.418176 IP (tos 0x0, ttl 62, id 40094, offset 0, flags [DF], proto TCP (6), length 52)
    192.168.1.2.48550 > 192.168.1.30.80: Flags [.], cksum 0x37e6 (correct), seq 1, ack 1, win 502, options [nop,nop,TS val 1964264951 ecr 557470897], length 0
2022-05-04 18:30:35.418626 IP (tos 0x0, ttl 62, id 40095, offset 0, flags [DF], proto TCP (6), length 337)
    192.168.1.2.48550 > 192.168.1.30.80: Flags [P.], cksum 0x23cf (correct), seq 1:286, ack 1, win 502, options [nop,nop,TS val 1964264952 ecr 557470897], length 285: HTTP, length: 285
    GET /api/v4/users?username=spike HTTP/1.1
    User-Agent: YouTrack/2022.1 (build #46592). Base URL: http://host02.mydomain.net/youtrack
    PRIVATE-TOKEN: -HscqhJymS7xqxeLy77z
    Host: gitlab.mydomain.net
    Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
    Connection: keep-alive
    
2022-05-04 18:30:35.418706 IP (tos 0x0, ttl 63, id 54631, offset 0, flags [DF], proto TCP (6), length 52)
    192.168.1.30.80 > 192.168.1.2.48550: Flags [.], cksum 0x0297 (incorrect -> 0x37d2), seq 1, ack 286, win 235, options [nop,nop,TS val 557470898 ecr 1964264952], length 0
2022-05-04 18:30:35.689063 IP (tos 0x0, ttl 63, id 54632, offset 0, flags [DF], proto TCP (6), length 1146)
    192.168.1.30.80 > 192.168.1.2.48550: Flags [P.], cksum 0x06dd (incorrect -> 0xee57), seq 1:1095, ack 286, win 235, options [nop,nop,TS val 557471168 ecr 1964264952], length 1094: HTTP, length: 1094
    HTTP/1.1 200 OK
    Server: nginx
    Date: Wed, 04 May 2022 09:30:35 GMT
    Content-Type: application/json
    Content-Length: 2
    Connection: keep-alive
    Cache-Control: max-age=0, private, must-revalidate
    Etag: W/"4f53cda18c2baa0c0354bb5f9a3ecbe5"
    Link: <http://gitlab.mydomain.net/api/v4/users?active=false&admins=false&blocked=false&external=false&order_by=id&page=1&per_page=20&skip_ldap=false&sort=desc&username=spike&with_custom_attributes=false&without_project_bots=false&without_projects=false>; rel="first", <http://gitlab.mydomain.net/api/v4/users?active=false&admins=false&blocked=false&external=false&order_by=id&page=1&per_page=20&skip_ldap=false&sort=desc&username=spike&with_custom_attributes=false&without_project_bots=false&without_projects=false>; rel="last"
    Vary: Origin
    X-Content-Type-Options: nosniff
    X-Frame-Options: SAMEORIGIN
    X-Next-Page: 
    X-Page: 1
    X-Per-Page: 20
    X-Prev-Page: 
    X-Request-Id: 01G276GD0VTSMXJPHH59T0CVHQ
    X-Runtime: 0.265008
    X-Total: 0
    X-Total-Pages: 1
    Strict-Transport-Security: max-age=63072000
    Referrer-Policy: strict-origin-when-cross-origin
    
    [][!http]
2022-05-04 18:30:35.690043 IP (tos 0x0, ttl 62, id 40096, offset 0, flags [DF], proto TCP (6), length 52)
    192.168.1.2.48550 > 192.168.1.30.80: Flags [.], cksum 0x307a (correct), seq 286, ack 1095, win 501, options [nop,nop,TS val 1964265202 ecr 557471168], length 0
2022-05-04 18:30:35.693428 IP (tos 0x0, ttl 62, id 40097, offset 0, flags [DF], proto TCP (6), length 380)
    192.168.1.2.48550 > 192.168.1.30.80: Flags [P.], cksum 0xa31a (correct), seq 286:614, ack 1095, win 501, options [nop,nop,TS val 1964265205 ecr 557471168], length 328: HTTP, length: 328
    GET /api/v4/projects?search=test00&simple=true&per_page=100&membership=true HTTP/1.1
    User-Agent: YouTrack/2022.1 (build #46592). Base URL: http://host02.mydomain.net/youtrack
    PRIVATE-TOKEN: -HscqhJymS7xqxeLy77z
    Host: gitlab.mydomain.net
    Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
    Connection: keep-alive
    
2022-05-04 18:30:35.693535 IP (tos 0x0, ttl 63, id 54633, offset 0, flags [DF], proto TCP (6), length 52)
    192.168.1.30.80 > 192.168.1.2.48550: Flags [.], cksum 0x0297 (incorrect -> 0x302c), seq 1095, ack 614, win 243, options [nop,nop,TS val 557471173 ecr 1964265205], length 0
2022-05-04 18:30:36.138660 IP (tos 0x0, ttl 63, id 54634, offset 0, flags [DF], proto TCP (6), length 2110)
    192.168.1.30.80 > 192.168.1.2.48550: Flags [P.], cksum 0x0aa1 (incorrect -> 0xd7c7), seq 1095:3153, ack 614, win 243, options [nop,nop,TS val 557471617 ecr 1964265205], length 2058: HTTP, length: 2058
    HTTP/1.1 200 OK
    Server: nginx
    Date: Wed, 04 May 2022 09:30:36 GMT
    Content-Type: application/json
    Content-Length: 748
    Connection: keep-alive
    Vary: Accept-Encoding
    Cache-Control: max-age=0, private, must-revalidate
    Etag: W/"13bd5bf8aa704d4c0cc42aba082e11a5"
    Link: <http://gitlab.mydomain.net/api/v4/projects?imported=false&membership=true&order_by=created_at&owned=false&page=1&per_page=100&repository_checksum_failed=false&search=test00&simple=true&sort=desc&starred=false&statistics=false&wiki_checksum_failed=false&with_custom_attributes=false&with_issues_enabled=false&with_merge_requests_enabled=false>; rel="first", <http://gitlab.mydomain.net/api/v4/projects?imported=false&membership=true&order_by=created_at&owned=false&page=1&per_page=100&repository_checksum_failed=false&search=test00&simple=true&sort=desc&starred=false&statistics=false&wiki_checksum_failed=false&with_custom_attributes=false&with_issues_enabled=false&with_merge_requests_enabled=false>; rel="last"
    Vary: Origin
    X-Content-Type-Options: nosniff
    X-Frame-Options: SAMEORIGIN
    X-Next-Page: 
    X-Page: 1
    X-Per-Page: 100
    X-Prev-Page: 
    X-Request-Id: 01G276GD9EWK2SW3E1F3NY6XMP
    X-Runtime: 0.440036
    X-Total: 1
    X-Total-Pages: 1
    Strict-Transport-Security: max-age=63072000
    Referrer-Policy: strict-origin-when-cross-origin
    
    [{"id":2,"description":"","name":"test00","name_with_namespace":"spike / test00","path":"test00","path_with_namespace":"spike/test00","created_at":"2022-05-04T08:37:40.740Z","default_branch":"main","tag_list":[],"topics":[],"ssh_url_to_repo":"git@gitlab.mydomain.net:spike/test00.git","http_url_to_repo":"http://gitlab.mydomain.net/spike/test00.git","web_url":"http://gitlab.mydomain.net/spike/test00","readme_url":"http://gitlab.mydomain.net/spike/test00/-/blob/main/README.md","avatar_url":null,"forks_count":0,"star_count":0,"last_activity_at":"2022-05-04T08:37:40.740Z","namespace":{"id":5,"name":"spike","path":"spike","kind":"group","full_path":"spike","parent_id":null,"avatar_url":null,"web_url":"http://gitlab.mydomain.net/groups/spike"}}][!http]
2022-05-04 18:30:36.139456 IP (tos 0x0, ttl 62, id 40098, offset 0, flags [DF], proto TCP (6), length 52)
    192.168.1.2.48550 > 192.168.1.30.80: Flags [.], cksum 0x23c9 (correct), seq 614, ack 3153, win 500, options [nop,nop,TS val 1964265617 ecr 557471617], length 0
2022-05-04 18:30:36.145083 IP (tos 0x0, ttl 62, id 40099, offset 0, flags [DF], proto TCP (6), length 387)
    192.168.1.2.48550 > 192.168.1.30.80: Flags [P.], cksum 0x9580 (correct), seq 614:949, ack 3153, win 501, options [nop,nop,TS val 1964265622 ecr 557471617], length 335: HTTP, length: 335
    POST /api/v4/projects/2/hooks HTTP/1.1
    User-Agent: YouTrack/2022.1 (build #46592). Base URL: http://host02.mydomain.net/youtrack
    PRIVATE-TOKEN: -HscqhJymS7xqxeLy77z
    Content-Type: application/json
    Host: gitlab.mydomain.net
    Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
    Connection: keep-alive
    Content-Length: 205
    
2022-05-04 18:30:36.145129 IP (tos 0x0, ttl 62, id 40100, offset 0, flags [DF], proto TCP (6), length 257)
    192.168.1.2.48550 > 192.168.1.30.80: Flags [P.], cksum 0x4938 (correct), seq 949:1154, ack 3153, win 501, options [nop,nop,TS val 1964265622 ecr 557471617], length 205: HTTP
2022-05-04 18:30:36.145710 IP (tos 0x0, ttl 63, id 54636, offset 0, flags [DF], proto TCP (6), length 52)
    192.168.1.30.80 > 192.168.1.2.48550: Flags [.], cksum 0x0297 (incorrect -> 0x2366), seq 3153, ack 949, win 252, options [nop,nop,TS val 557471624 ecr 1964265622], length 0
2022-05-04 18:30:36.145987 IP (tos 0x0, ttl 63, id 54637, offset 0, flags [DF], proto TCP (6), length 52)
    192.168.1.30.80 > 192.168.1.2.48550: Flags [.], cksum 0x0297 (incorrect -> 0x2291), seq 3153, ack 1154, win 260, options [nop,nop,TS val 557471624 ecr 1964265622], length 0
2022-05-04 18:30:36.257101 IP (tos 0x0, ttl 63, id 54638, offset 0, flags [DF], proto TCP (6), length 410)
    192.168.1.30.80 > 192.168.1.2.48550: Flags [P.], cksum 0x03fd (incorrect -> 0xc9cd), seq 3153:3511, ack 1154, win 260, options [nop,nop,TS val 557471736 ecr 1964265622], length 358: HTTP, length: 358
    HTTP/1.1 422 Unprocessable Entity
    Server: nginx
    Date: Wed, 04 May 2022 09:30:36 GMT
    Content-Type: application/json
    Content-Length: 29
    Connection: keep-alive
    Cache-Control: no-cache
    Vary: Origin
    X-Content-Type-Options: nosniff
    X-Frame-Options: SAMEORIGIN
    X-Request-Id: 01G276GDQKFHYTWPE09Q4TW1BH
    X-Runtime: 0.105369
    
    {"error":"Invalid url given"}[!http]
2022-05-04 18:30:36.257793 IP (tos 0x0, ttl 62, id 40101, offset 0, flags [DF], proto TCP (6), length 52)
    192.168.1.2.48550 > 192.168.1.30.80: Flags [.], cksum 0x1f61 (correct), seq 1154, ack 3511, win 501, options [nop,nop,TS val 1964265727 ecr 557471736], length 0

3 comments
Comment actions Permalink

Hello,

Have you tried clicking the 'here' button as the error message suggests?

0
Comment actions Permalink

Yes. Clicking the 'here' button guided me to a document page where I've got the knowledge to add -Djetbrains.youtrack.webHooksBaseUrl=http://host02.mydomain.net/youtrack option in youtrack.jvmoptions, as I wrote above.

0
Comment actions Permalink

I J E X A

Please also enable the Allow requests to the local network from hooks and services in the Outbound requests section of the page at the Admin Area > Settings menu for your GitLab server as the page suggests.

0

Please sign in to leave a comment.