microsoft / azure-pipelines-vscode

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

Incorrect type. Expected "string" when using a boolean value #330

Open amrock-my opened 4 years ago

amrock-my commented 4 years ago

Our YAML file begins as so:

trigger:
  batch: true
  branches:
    include:
      - master
  paths:
    exclude:
      - README.md

This extension complains about the usage of batch: true: Incorrect type. Expected "string". The pipeline still works, and I worry that if I use "true" instead of true that it might be treated as a scalar value, in which case "false" will still evaluate to true.

Even the documentation shows an example of using the boolean value:

trigger:
  batch: true
  branches:
    include:
    - features/*
    exclude:
    - features/experimental/*
  paths:
    exclude:
    - README.md

This is similar to issue #283 which has the intellisense incorrectly complaining about another part of the yaml.


Extension Version: v1.170.0

Version: 1.46.1 (user setup) Commit: cd9ea6488829f560dc949a8b2fb789f3cdc05f5d Date: 2020-06-17T21:13:20.174Z Electron: 7.3.1 Chrome: 78.0.3904.130 Node.js: 12.8.1 V8: 7.8.279.23-electron.0 OS: Windows_NT x64 10.0.18363

jlpstolwijk commented 3 years ago

same issue here

ashkantaravati commented 3 years ago

same here

asilverman commented 3 years ago

same here

mrlunchbox777 commented 3 years ago

same issue that I attempted to fix improperly here, there are several places that this happens - https://github.com/microsoft/azure-pipelines-vscode/pull/417

mrlunchbox777 commented 3 years ago

@50Wliu I know on that PR you said that we can't edit the file directly and that the file is managed internally, does that mean there is no way to contribute to fixing these kind of issues? I'd gladly spend some time fixing some of these if there is a way we can contribute.

50Wliu commented 3 years ago

Not that I know of, unfortunately. It actually seems to be auto-generated, meaning that it's even harder to fix than I thought 😢.

50Wliu commented 3 years ago

Okay, did some more digging. I'm pretty sure that for tasks, the schema is auto-generated from each task's task.json file. So if you're seeing problems with an individual task's validation, go submit a PR to https://github.com/microsoft/azure-pipelines-tasks. Still don't know how the rest of it (i.e. trigger, etc) is generated though.

AlexanderVolkovDA commented 2 years ago

I guess I've found the reason of issue: trigger's batch property is defined on line 963 in service-schema.json And the type is #/definitions/boolean that is defined on line 3995 in the same file all of types are string values.

I see two possible solutions:

  1. change type of batch property to boolean
  2. add boolean value in a definition of #/definitions/boolean

I'm quite new in open source. Should I just create a PR or how do you guys propose changes here? 😃

50Wliu commented 2 years ago

Hey @AlexanderVolkovDA!

I'm quite new in open source. Should I just create a PR

Typically, this is exactly how you would do it! However, in this case, the schema is auto-generated, so any manual changes to the PR will get overwritten on the next release. If you'd like, you can create a ticket on Developer Community; otherwise, I'll get to creating the ticket myself eventually.

petrnymsa commented 2 years ago

Hey @AlexanderVolkovDA!

I'm quite new in open source. Should I just create a PR

Typically, this is exactly how you would do it! However, in this case, the schema is auto-generated, so any manual changes to the PR will get overwritten on the next release. If you'd like, you can create a ticket on Developer Community; otherwise, I'll get to creating the ticket myself eventually.

Is ticket already created? Can't find it and I don't want to create duplicates.

50Wliu commented 2 years ago

I haven't created it! Feel free to create one and link it here @petrnymsa.

Charles-Gagnon commented 2 years ago

Came across this since I noticed the same issue - seems like there's a ticket that was opened for this but closed as "not enough information"

https://developercommunity.visualstudio.com/t/Azure-Pipelines-schema-inconsistently-li/1668070

I opened a new ticket to see if we can get an actual answer on this (and similar classes of issues) https://developercommunity.visualstudio.com/t/YAML-schema-has-incorrect-type-for-boole/10097973

tigerhawkvok commented 1 month ago

This is still open, and still a problem.

Note this example:

image

Note in service-schema.json,

a pipeline parameter

https://github.com/microsoft/azure-pipelines-vscode/blob/bda2f993c64f3601ff14c70e96aa2014aa2d640d/service-schema.json#L47-L75

Has items of PipelineTemplateParameters

https://github.com/microsoft/azure-pipelines-vscode/blob/bda2f993c64f3601ff14c70e96aa2014aa2d640d/service-schema.json#L1181-L1202

for which default has an allowed definition of any. It ends up that any is defined as:

https://github.com/microsoft/azure-pipelines-vscode/blob/bda2f993c64f3601ff14c70e96aa2014aa2d640d/service-schema.json#L30-L46

Conspicuously, boolean is missing.