Skip to content

CI Lint API Does not properly handle template includes

Summary

Using a custom template include inside a .gitlab-ci.yml causes the CI lint API to fail. This causes problems with automating checks against the .gitlab-ci.yml in e.g. a git hook.

Steps to reproduce

Add an include block, e.g.

include:
  - project: 'templates/ci'
    file: 'anything.yml'

Then attempt to validate the .gitlab-ci.yml against the API:

$ curl -H "Content-Type: application/json" https://git.[redacted].com/api/v4/ci/lint --data "$(jq -Rs '{ content: . }' .gitlab-ci.yml)"
{"status":"invalid","errors":["Project `templates/ci` not found or access denied!"]}

Note that both the application project/group is marked Private and the templates project/group is marked Internal in this case.

What is the current bug behavior?

The API incorrectly returns an error, even though the CI file is actually valid. Using the CI Lint tool in the UI at e.g. https://git.[redacted].com/templates/ci/-/ci/lint actually correctly validates the .gitlab-ci-yml file.

What is the expected correct behavior?

The CI Lint API should validate custom template include blocks. It should also produce the same results as using the CI Lint tool inside the GitLab UI.

Output of checks

(If you are reporting a bug on GitLab.com, write: This bug happens on GitLab.com)

Results of GitLab environment info

Expand for output related to GitLab environment info

System information
System:		Debian 8.11
Proxy:		RSYNC_PROXY: [redacted]
		HTTPS_PROXY: http://[redacted]
		rsync_proxy: [redacted]
		https_proxy: http://[redacted]
		ALL_PROXY: http://[redacted]
		http_proxy: http://[redacted]
		HTTP_PROXY: http://[redacted]
Current User:	git
Using RVM:	no
Ruby Version:	2.6.5p114
Gem Version:	2.7.10
Bundler Version:1.17.3
Rake Version:	12.3.3
Redis Version:	5.0.7
Git Version:	2.26.2
Sidekiq Version:5.2.7
Go Version:	unknown

GitLab information
Version:	12.10.1-ee
Revision:	695c29abcf7
Directory:	/opt/gitlab/embedded/service/gitlab-rails
DB Adapter:	PostgreSQL
DB Version:	11.7
URL:		https://git.[redacted].com
HTTP Clone URL:	https://git.[redacted].com/some-group/some-project.git
SSH Clone URL:	git@git.[redacted].com:some-group/some-project.git
Elasticsearch:	yes
Geo:		no
Using LDAP:	yes
Using Omniauth:	yes
Omniauth Providers: 

GitLab Shell
Version:	12.2.0
Repository storage paths:
- default: 	/var/opt/gitlab/git-data/repositories
GitLab Shell path:		/opt/gitlab/embedded/service/gitlab-shell
Git:		/opt/gitlab/embedded/bin/git

Results of GitLab application Check

Expand for output related to the GitLab application check

Checking GitLab subtasks ...

Checking GitLab Shell ...

GitLab Shell: ... GitLab Shell version >= 12.2.0 ? ... OK (12.2.0) Running /opt/gitlab/embedded/service/gitlab-shell/bin/check Internal API available: OK Redis available via internal API: OK gitlab-shell self-check successful

Checking GitLab Shell ... Finished

Checking Gitaly ...

Gitaly: ... default ... OK

Checking Gitaly ... Finished

Checking Sidekiq ...

Sidekiq: ... Running? ... yes Number of Sidekiq processes ... 1

Checking Sidekiq ... Finished

Checking Incoming Email ...

Incoming Email: ... Reply by email is disabled in config/gitlab.yml

Checking Incoming Email ... Finished

Checking LDAP ...

LDAP: ... Server: ldapmain not verifying SSL hostname of LDAPS server '[redacted]' LDAP authentication... Success LDAP users with access to your GitLab server (only showing the first 100 results) User output sanitized. Found 17 users of 100 limit.

Checking LDAP ... Finished

Checking GitLab App ...

Git configured correctly? ... yes Database config exists? ... yes All migrations up? ... yes Database contains orphaned GroupMembers? ... no GitLab config exists? ... yes GitLab config up to date? ... yes Log directory writable? ... yes Tmp directory writable? ... yes Uploads directory exists? ... yes Uploads directory has correct permissions? ... yes Uploads directory tmp has correct permissions? ... yes Init script exists? ... skipped (omnibus-gitlab has no init script) Init script up-to-date? ... skipped (omnibus-gitlab has no init script) Projects have namespace: ... 3/3 ... yes 8/5 ... yes 3/6 ... yes 7/7 ... yes 3/8 ... yes 3/13 ... yes 15/14 ... yes 15/15 ... yes 15/16 ... yes 3/20 ... yes 24/21 ... yes 3/22 ... yes 3/23 ... yes 3/25 ... yes 8/31 ... yes 8/33 ... yes 8/34 ... yes 8/35 ... yes 8/36 ... yes 8/38 ... yes 21/39 ... yes 21/40 ... yes 21/41 ... yes 21/42 ... yes 8/43 ... yes 3/50 ... yes 3/51 ... yes 15/52 ... yes 3/53 ... yes 21/54 ... yes 3/56 ... yes 48/57 ... yes 3/58 ... yes 36/59 ... yes 23/60 ... yes 5/61 ... yes 48/62 ... yes 3/63 ... yes 15/64 ... yes 3/65 ... yes 23/66 ... yes 48/68 ... yes 3/69 ... yes 36/71 ... yes 48/73 ... yes 38/74 ... yes 48/75 ... yes 3/76 ... yes 3/77 ... yes 36/79 ... yes 36/80 ... yes 36/81 ... yes 36/82 ... yes 38/83 ... yes 34/84 ... yes 36/85 ... yes 7/86 ... yes 36/87 ... yes 38/88 ... yes 36/92 ... yes 23/93 ... yes 41/94 ... yes 36/95 ... yes 38/96 ... yes 36/99 ... yes 36/100 ... yes 36/101 ... yes 43/102 ... yes 7/103 ... yes 36/105 ... yes 41/107 ... yes 23/108 ... yes 38/109 ... yes 36/110 ... yes 36/111 ... yes 3/112 ... yes 3/113 ... yes 60/114 ... yes 36/115 ... yes 3/116 ... yes 38/117 ... yes 3/118 ... yes 36/119 ... yes 3/120 ... yes 38/121 ... yes 36/122 ... yes 23/123 ... yes 23/124 ... yes 38/125 ... yes 38/126 ... yes 38/127 ... yes 38/128 ... yes 7/129 ... yes 48/130 ... yes 36/131 ... yes 3/132 ... yes 23/133 ... yes 3/134 ... yes 3/135 ... yes 47/137 ... yes 38/138 ... yes 3/139 ... yes 23/140 ... yes 7/141 ... yes 7/142 ... yes 36/143 ... yes 38/144 ... yes 38/145 ... yes 3/148 ... yes 41/150 ... yes 48/151 ... yes 43/152 ... yes 41/153 ... yes 36/154 ... yes 3/155 ... yes 3/156 ... yes 3/157 ... yes 41/158 ... yes 52/159 ... yes 52/160 ... yes 52/161 ... yes 48/162 ... yes 41/163 ... yes 2/164 ... yes 36/165 ... yes 23/166 ... yes 48/167 ... yes 48/168 ... yes 36/170 ... yes 48/171 ... yes 48/172 ... yes 48/173 ... yes 7/174 ... yes 23/176 ... yes 36/177 ... yes 23/178 ... yes 36/179 ... yes 38/180 ... yes 49/181 ... yes 48/183 ... yes 23/185 ... yes 36/186 ... yes 48/187 ... yes 36/188 ... yes 48/189 ... yes 48/190 ... yes 48/191 ... yes 36/192 ... yes 48/193 ... yes 60/195 ... yes 48/196 ... yes 38/197 ... yes 36/198 ... yes 38/199 ... yes 60/200 ... yes 23/201 ... yes 48/202 ... yes 48/203 ... yes 36/204 ... yes 49/205 ... yes 48/206 ... yes 38/207 ... yes 23/208 ... yes 36/209 ... yes 7/210 ... yes 7/211 ... yes 7/212 ... yes 48/213 ... yes 36/214 ... yes 7/215 ... yes 38/218 ... yes 7/219 ... yes 38/220 ... yes 7/221 ... yes 67/222 ... yes 67/223 ... yes 67/224 ... yes 38/225 ... yes 38/226 ... yes 68/227 ... yes 69/228 ... yes 3/229 ... yes 48/230 ... yes 48/231 ... yes 48/232 ... yes 69/233 ... yes 23/234 ... yes 38/235 ... yes 67/236 ... yes 67/237 ... yes 67/238 ... yes 69/239 ... yes 69/240 ... yes 7/241 ... yes 67/242 ... yes 67/243 ... yes 67/245 ... yes 67/246 ... yes 67/247 ... yes 23/249 ... yes 69/250 ... yes 69/251 ... yes 71/252 ... yes 67/253 ... yes 38/254 ... yes 71/255 ... yes 23/256 ... yes 7/257 ... yes 71/258 ... yes 7/259 ... yes 67/260 ... yes 23/261 ... yes 7/262 ... yes 7/263 ... yes 38/264 ... yes 72/265 ... yes 72/266 ... yes 23/267 ... yes 23/268 ... yes 73/269 ... yes Redis version >= 4.0.0? ... yes Ruby version >= 2.5.3 ? ... yes (2.6.5) Git version >= 2.22.0 ? ... yes (2.26.2) Git user has default SSH configuration? ... yes Active users: ... 10 Is authorized keys file accessible? ... yes Elasticsearch version 5.6 - 6.x? ... yes (7.6.2)

Checking GitLab App ... Finished

Checking GitLab subtasks ... Finished

Possible fixes

(If you can, link to the line of code that might be responsible for the problem)

Edited by Jeff Mixon