Skip to content

Misleading YAML error when variable set to integer

Summary

If .gitlab-ci.yml contains a variables: section with a variable set to a numeric value (e.g., SERVICE_PORT: 8080), the Gitlab CI runner reports "yaml invalid" with tooltip "variables config should be a hash of key value pairs". This is misleading - it is a hash of key value pairs, but one of the values is an integer and it is required to be a string.

Steps to reproduce

variables:
  SERVICE_PORT: 8080

What is the current bug behavior?

Pipeline shows "yaml invalid" and tooltip says "variables config should be a hash of key value pairs"

What is the expected correct behavior?

Pipeline shows "yaml invalid" and tooltip says "variables config should be a hash of key value pairs. Keys and values must be strings"

Relevant logs and/or screenshots

Output of checks

Results of GitLab environment info

Results of GitLab application Check

Possible fixes

https://gitlab.com/gitlab-org/gitlab-ce/blob/master/lib/gitlab/ci/config/entry/validators.rb#L119

Notice that validate_variables also requires that key and value are string or symbol:

https://gitlab.com/gitlab-org/gitlab-ce/blob/master/lib/gitlab/ci/config/entry/legacy_validation_helpers.rb#L24