[go: up one dir, main page]

Skip to content

Nested object in default YAML inputs get mangled

Summary

Consider .gitlab.yml with inputs entry:

spec:
  inputs:
    package_overrides:
      type: array
      description: "Unity packages to override in manifest.json"
      default:
        - com.unity.collections: "2.4.3"
        - com.unity.mathematics: "1.3.2"
---

deploy_job:
  stage: deploy
  dependencies: [] # do not download artifacts
  rules:
    - if: $CI_PIPELINE_SOURCE == "web"
    - if: $CI_PIPELINE_SOURCE == "schedule"
    - if: $CI_MERGE_REQUEST_ID
      when: manual
      allow_failure: true
  script:
    - export PACKAGE_OVERRIDES='$[[ inputs.package_overrides ]]'

As far as I understand, default value for $[[ inputs.package_overrides ]] should be some form of 2-element array containing name -> version mapping.

As can be checked in CI lint (https://gitlab.com/R2RT/scheduled-pipelined-inputs-bug/-/ci/lint), its value gets expanded to:

'[{:"com.unity.collections"=>"2.4.3"}, {:"com.unity.mathematics"=>"1.3.2"}]'

JSON equivalent for dummies:

[
    {
        ":\"com.unity.collections\"=>\"2.4.3\"": null
    },
    {
        ":\"com.unity.mathematics\"=>\"1.3.2\"": null
    }
]

I would rather expect to see YAML equivalent of

[
    {
        "com.unity.collections": "2.4.3"
    },
    {
        "com.unity.mathematics": "1.3.2"
    }
]

Steps to reproduce

  1. Paste my example yml to CI Lint.
  2. See expanded command in Deploy Job - deploy_job row.

Example Project

https://gitlab.com/R2RT/scheduled-pipelined-inputs-bug

What is the current bug behavior?

For

      default:
        - com.unity.collections: "2.4.3"
        - com.unity.mathematics: "1.3.2"

default gets converted to:

'[{:"com.unity.collections"=>"2.4.3"}, {:"com.unity.mathematics"=>"1.3.2"}]'

What is the expected correct behavior?

Valid single-line YAML array which maintains its structure: e.g.

[{com.unity.collections: 2.4.3}, {com.unity.mathematics: 1.3.2}]

Or simply multiline one:

- com.unity.collections: 2.4.3
- com.unity.mathematics: 1.3.2

Relevant logs and/or screenshots

image

Output of checks

This bug happens on GitLab.com

Possible fixes

Edited by 🤖 GitLab Bot 🤖