CircleCI-Public / circleci-yaml-language-server

The official language server for CircleCI YAML configuration files
Apache License 2.0
20 stars 18 forks source link

fix: error when passing an enum to a string param #259

Closed abdelDriowya closed 11 months ago

abdelDriowya commented 11 months ago

Jira

Description

False “parameter must be a string” error when passing an enum

Implementation details

Avoid creating an error when passed parameter type is enum and definition is string

How to validate

test config file


version: 2.1

orbs:
  android: circleci/android@2.3.0

commands:

  stringeater-choking-on-enums:
    parameters:
      string-parameter:
        type: string
    steps:
      - run: echo "do nothing"

jobs:
  parametric-job:
    resource_class: large
    docker:
      - image: cimg/android:2021.12.2-node
    parameters:
      enum-parameter:
        type: enum
        default: apple
        enum:
          - apple
          - orange
    steps:
      - store_artifacts:
          path: << parameters.enum-parameter >>
      - stringeater-choking-on-enums:
          string-parameter: << parameters.enum-parameter >>
      - stringeater-choking-on-enums:
          string-parameter: << parameters.enum-parameter >> ""
      - android/fastlane-deploy:
          lane-name: << parameters.enum-parameter >>

workflows:
  build:
    jobs:
      - parametric-job:
          enum-parameter: apple
      - parametric-job:
          enum-parameter: orange```
abdelDriowya commented 11 months ago

LGTM

I have one comment about readability. Also, do you think you could add a non-regression test in parameters_test.go?

I tried adding tests, it requires rewritting a lot of the logic that trigger the error; it would have been easier with snapshot tests, I think we removed them ?

loderunner commented 11 months ago

Alright. I guess test refactoring will be for another day, then. Approved.