microsoft / azure-pipelines-vscode

VS Code extension for working with Azure Pipelines YAML files
MIT License
163 stars 103 forks source link

use of step aliases causes false-positive errors #523

Open jtmoon79 opened 1 year ago

jtmoon79 commented 1 year ago

tl;dr using an aliased task step input type results in VS Code Extension errant marking an error

Problem

The following Azure Pipeline yaml code is validated using using the current latest service-schema.json 97f39ff988232860b35556dde725d448151ec5a0

This yaml code is okay, according to azure-pipelines-vscode extension.

# yaml-language-server: $schema=https://raw.githubusercontent.com/microsoft/azure-pipelines-vscode/97f39ff988232860b35556dde725d448151ec5a0/service-schema.json
stages:
- stage: Stage 1
  jobs:
  - job: Job_1
    steps:
    - task: DownloadPipelineArtifact@2
      inputs:
        buildType: 'specific'
        project: 'Project2'
        definition: 'definition2'
        buildVersionToDownload: 'specific'
        pipelineId: $(myId)
        artifactName: 'artifact2'
        targetPath: '.'

Now the same yaml but using aliases. Alias runVersion for step input buildVersionToDownload. Alias runId for step input pipelineId.

This yaml code is not okay, according to azure-pipelines-vscode extension.

# yaml-language-server: $schema=https://raw.githubusercontent.com/microsoft/azure-pipelines-vscode/97f39ff988232860b35556dde725d448151ec5a0/service-schema.json
stages:
- stage: Stage 1
  jobs:
  - job: Job_1
    steps:
    - task: DownloadPipelineArtifact@2
      inputs:
        buildType: 'specific'
        project: 'Project2'
        definition: 'definition2'
        runVersion: 'specific'
        runId: $(myId)
        artifactName: 'artifact2'
        targetPath: '.'

VS Code red underlines several parts and reports error

Property runVersion is now allowed: Pipeline schema

and odd error

String does not match the pattern of "^PowerShell@1$".yaml-schema: Pipeline schema

Screenshot

Solution

It appears the aliases are not checked for task step inputs. Looking at the JSON schema (from 97f39ff988232860b35556dde725d448151ec5a0) there is

        {
          "properties": {
            "task": {
              "description": "Download Pipeline Artifacts\n\nDownload build and pipeline artifacts",
              "ignoreCase": "value",
              "pattern": "^DownloadPipelineArtifact@2$"
            },
         // ...
                "buildVersionToDownload": {
                  "description": "Build version to download",
                  "ignoreCase": "all",
                  "enum": [
                    "latest",
                    "latestFromBranch",
                    "specific"
                  ],
                  "aliases": [
                    "runVersion"
                  ]
                },
        // ...
                "pipelineId": {
                  "type": "string",
                  "description": "Build",
                  "ignoreCase": "key",
                  "aliases": [
                    "runId",
                    "buildId"
                  ]
                },

So the validator portion of azure-pipelines-vscode should also try to match task step input names with entries in the task step input list aliases.

jtmoon79 commented 1 year ago

Relates to #184 , #120

vmapetr commented 1 year ago

Hi, @jtmoon79 thanks for reporting! We are working on more prioritized issues at the moment but will get back to this one soon.

50Wliu commented 1 year ago

Also unable to repro: image