False "parameter must be a string" error when passing an enum

Hi,

I would like to mention a minor annoyance in the VS Code extension.

The cci-language-server always reports an error when I am trying to pass an enum parameter to a command that expects a string parameter. This is however perfectly ok, as enum parameter is just a string parameter restricted to a few values. Once committed and pushed, the pipeline reports no errors and runs correctly.

The problem happens only when the command is my own or from a third-party orb. There are no complaints about passing to a string-consuming CircleCI builtin command, such as store_artifacts.

A workaround is to concatenate the parameter with an empty string, but it is confusing and adds a space at the end I believe.

Here is a copyable version of the code:

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

Also, perhaps off topic, I cannot get any suggestions or error reprimands from the same cci-language-server when I am editing a command that lives in its own yml file in an orb repository. That is, the functionality is limited to the .circleci/config.yml file of any repository. Is this the way it is, or did I just fail to activate some setting?

These autosuggestions and error highlighting are a godsend and it would be pleasant to have them also when editing an orb.

Thanks!

The possible values for a enum are themselves strings so one thing to try would be to place the values in double quotes as shown in the docs here

Thank you! I tried your suggestion, but sadly none of the following work:




OK, so it is not vs code getting the type checking wrong due to the way that the enum is expressed, but instead it is getting it wrong for some reason when the enum is passed as a parameter to an Orb based command that is defining a parameter as accepting a string (while accepting it when using locally defined commands).

I’m just someone external helping out so have no contacts within the developer teams, but it would be worth you raising a support ticket so that the issue can be passed on to the correct people.

Hi @martin.drozdik, I’m the PM of the Developer Experience team , who is responsible for the Language Server and the extension. My apologies, we’d completely missed this post!

This is definitely something we can and should fix on our side, we actually didn’t realise that enum parameters could be downcast this way in the config. We won’t be able to jump on this immediately, but we should be able to release a fix by the end of July - I’ll keep you posted.

As for enabling validation or Orbs through the Language Server - It’s something we are considering but there are some issues we need to address first. Again, I’d be happy to let you know if/when we commit to this.

In the meantime, I’m pleased you’re finding LS-based validation useful (beyond the very understandable annoyance of the red squiggly line that shouldn’t be there)

Hi @Benny, any news on this? Having 0 error output IDE is always nice. Thanks.