CI Yaml Lint error doesn't display error for includes when local requests are disabled
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
Problem to solve
When the Allow requests to the local network from hooks and services is disabled the CI Linter will fail with an syntax remote file is invalid error.
This causes confusion as its suppressing the real error (and the file actually is valid yaml).
Status: syntax is incorrect
Error: Remote file 'https://10.0.2.15/root/public/raw/master/.before-script-template.yml' is not valid.
Further details
It looks like its due to the nil being returned on any error: https://gitlab.com/gitlab-org/gitlab-ee/blob/v11.2.3-ee/ee/lib/gitlab/ci/external/file/remote.rb
begin
Gitlab::HTTP.get(location)
rescue Gitlab::HTTP::Error, Timeout::Error, SocketError, Gitlab::HTTP::BlockedUrlError
nil
end
The error is being thrown here, but the error handler returns nil instead, which becomes invalid syntax.
irb(main):001:0> Gitlab::HTTP.get('https://10.0.2.15/root/public/raw/master/template.yml')
Gitlab::HTTP::BlockedUrlError: URL 'https://10.0.2.15/root/public/raw/master/template.yml' is blocked: Requests to localhost are not allowed
Proposal
Bubble up the error and return the root cause of the problem.
What does success look like, and how can we measure that?
Displaying the error during linting:
URL 'https://10.0.2.15/root/public/raw/master/template.yml' is blocked: Requests to localhost are not allowed
Links / references
Internal ZD: https://gitlab.zendesk.com/agent/tickets/102212
