Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect type. Expected "string | array | object(Azure Pipelines)" when using number parameter #513

Closed
james-woodbridge opened this issue Mar 16, 2023 · 8 comments
Assignees
Labels
accurate-yaml-validation Fidelity of matching YAML features Area: VsCodeExtension

Comments

@james-woodbridge
Copy link

Current behaviour

Pipeline validation raises an error stating Incorrect type. Expected "string | array | object(Azure Pipelines)" when using a parameter with the number type and a default value. For example:

parameters:
  - name: timeoutInMinutes
    type: number
    default: 60

Expected behavior

Pipeline validation does not raise an error for a number parameter having a numerical default.

Suggestion

Potentially resolved by adding "type": "number" to the list of types in the #definitions/any/anyOf section of the schema

@sergey-koryshev
Copy link

Hi @james-woodbridge, thank you for reporting the issue, we will take a look at it in order of priority

@ivanduplenskikh ivanduplenskikh self-assigned this Mar 21, 2023
@ivanduplenskikh
Copy link
Contributor

@james-woodbridge, I can't reproduce this behavior.
I have created azure-pipelines.yml with the next content:

parameters:
  - name: timeoutInMinutes
    type: number
    default: 60

jobs:
  - name: Run a one-line script
    script: echo Hello, world!

This YAML passed as valid.

@kirill-ivlev
Copy link

Hi @james-woodbridge,
Could you please confirm that you still facing this issue?

@james-woodbridge
Copy link
Author

Hi @kirill-ivlev and @ivanduplenskikh

I am still seeing this issue. My parameters block looks like this:

parameters:
  - name: environment_name
    default: ''
  - name: environment_slug
    default: ''
  - name: dependsOn
    default: 'Precheck'
  - name: condition
    default: "succeeded('Precheck')"
  - name: agentPool
    default: 'ubuntu-20.04'
  - name: timeoutInMinutes
    type: number
    default: 60
  - name: build
    default: $(Build.BuildNumber)
  - name: terraformVersion
    default: 1.2.2
  - name: apply_condition
    default: "in(variables['Build.SourceBranch'], 'refs/heads/master', 'refs/heads/main')"
  - name: service_connection
    default: ''
  - name: storage_account_rg
    default: ''
  - name: storage_account_name
    default: ''
  - name: infrastructure_pipeline_repository
    type: string
    default: SharedPipeline
  - name: azure_subscription
    default: ''
  - name: keyVault_name
    default: ''
  - name: sops_kv_name
    default: ''

and I'm using v1.208.0 of the Azure Pipelines extension and v1.78.2 of vscode.

picture of the error here:
image

@ivanduplenskikh
Copy link
Contributor

@james-woodbridge, are you using a custom service schema in your project workspace?

@Sialagio
Copy link

Hey,

I'm facing the same issue, but not in the parameters.

GetVersion:
    stage: publish
  tags:
    - docker
  script:
    - versionLine=$(sed '46q;d' ./somefile.yml)
    - extractedVersion=${versionLine: -23}  #Where I get the eror

@vritant24
Copy link
Member

I'm seeing a similar issue:
image
image

Seeing this on:
Azure pipelines version v1.228.0
vscode version:

Version: 1.83.0-insider (user setup)
Commit: e7e037083ff4455cf320e344325dacb480062c3c
Date: 2023-10-03T13:48:08.540Z
Electron: 25.8.4
ElectronBuildId: 24154031
Chromium: 114.0.5735.289
Node.js: 18.15.0
V8: 11.4.183.29-electron.0
OS: Windows_NT x64 10.0.22621

@winstliu
Copy link
Member

Okay, I think I know what's going on here. Please make sure that the file language is set to "Azure Pipelines", not YAML. My hunch is that if you also have the YAML extension installed (and have the language set to YAML), you'll get the YAML extension's schema detection which doesn't work because the Pipelines schema is a little non-standard. (Which is also, incidentally, why we needed to fork the YAML language server.)

vs-code-file-language

I'll close this for now but please let me know if you continue to see this even when the language is set correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accurate-yaml-validation Fidelity of matching YAML features Area: VsCodeExtension
Projects
None yet
Development

No branches or pull requests

7 participants