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

Inconsistent validation based on file extension (file.yml vs file.yaml) #288

Closed
OpsTalkJordan opened this issue Mar 22, 2020 · 6 comments
Closed
Labels

Comments

@OpsTalkJordan
Copy link

OpsTalkJordan commented Mar 22, 2020

Upon saving a yaml file as .yml previous valid yaml syntax reports invalid.

Operating System: Windows 10
VS Code Release: 1.43.1
YAML Extension Version: 0.7.2

Steps to reproduce:

  1. Open a new workspace.
  2. Set language mode to YAML.
  3. Insert valid yaml syntax, for example:
plugins:
  - name: "Plugin 1"
    date: "Mar 21 2020"
    licenseKey: |
      line1
      line2

  - name: "Plugin 2"
    date: "Mar 21 2020"
    licenseKey: |
      line1
      line2
  1. Save file without specifying extension (defaults to .yml)

File > Save > "fileName"

At this point all previously valid syntax reports 'Incorrect type. Expected "string".'

  1. Save file specifying the yaml extension.

File > Save as > "fileName.yaml"

All syntax now reports correct again.

Specifically the filename I tested with is "myAppConfig" and follows the exact same formatting as above. It is being saved in the default Windows 10 document folder and using "Spaces 2" indentation. Verified no trailing white space and that both files validate fine with a up to data Python3 yamllint install.

@JPinkney
Copy link
Contributor

Most likely the file name you are using is automatically associating with one of the schemas from http://schemastore.org/json/ based on:

Incorrect type. Expected "string".'

because the only way this should show is if its comparing against a json schema.

If you want to turn off this feature you can turn off yaml.schemaStore.enable

@gorkem
Copy link
Collaborator

gorkem commented Jun 11, 2020

Closing since this went silent

@gorkem gorkem closed this as completed Jun 11, 2020
@vdh
Copy link

vdh commented Aug 19, 2020

@JPinkney @gorkem So is there any way to actually debug or fix this issue with the Schema Store? It's impossible to even figure out what it's pulling from the store, because the error messages don't explain or provide sources for themselves.

This seems like it's a pretty big flaw in the Schema Store feature if it just silently picks a false positive for validation. It took me quite a while to trace it back to this extension and this particular issue, simply because Missing property "app". was an extremely unhelpful error message that failed to mention neither the validator (vscode-yaml), nor what incorrect schema it decided to randomly pick for my .mocharc.yml file.

@JPinkney
Copy link
Contributor

The only way is to fix it is to modify the json schema in the json schema store repository https://github.com/SchemaStore/schemastore

@vdh
Copy link

vdh commented Aug 20, 2020

@JPinkney Which schema file…? This is the issue.

Other linters like ESLint or Typescript will identify themselves in the Problems pane, and directly link to their validation source (ESLint with external doc links, or TS with error codes). vscode-yaml is anonymous and lacking any info to trace which schema is complaining, thereby making it impossible to find false-positives and fix them.

@gorkem
Copy link
Collaborator

gorkem commented Aug 21, 2020

Extending diagnostics is a good idea opened redhat-developer/yaml-language-server#310

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants