Allow hyphenated input names in CI array index access

What does this MR do and why?

CI/CD inputs can have hyphenated names and array values, but accessing an array element by index failed when the input name contained a hyphen:

spec:
  inputs:
    supported-versions:
      type: array
      default: ['2.0', '1.0']
---
test:
  script: echo $[[ inputs.supported-versions[0] ]]

This was rejected with invalid array index syntax in `inputs.supported-versions[0]`​, while inputs.supported_versions[0] worked.

The indexed-segment pattern in Interpolation::Access only allowed word characters for the base key. This MR accepts hyphens there too, matching the pattern already used for input names in Gitlab::Ci::Pipeline::Expression::Lexeme::Input.

Resolves #627813 (closed)

References

How to set up and validate locally

  1. Open the CI/CD pipeline editor (or the CI Lint page) in any project.
  2. Paste the configuration from the description above.
  3. Before this change, validation fails with invalid array index syntax.
  4. After this change, the configuration is valid and the merged YAML shows script: echo 2.0.

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Manuel Grabowski

Merge request reports

Loading
Loading