vscode-yaml
vscode-yaml copied to clipboard
Wrong schema chosen when using the filename `deploy.yml` despite under `.github/workflows`
Describe the bug
When filename is deploy.yml
the deployer recipe is chosen instead of the github workflow schema
When filename is NOT deploy.yml
, github workflow schema is chosen
related to #488
Expected Behavior
Any yml file under .github/workflows
should use github workflow schema
Current Behavior
Version: 1.62.2 Commit: 3a6960b964327f0e3882ce18fcebd07ed191b316 Date: 2021-11-11T20:59:05.913Z Electron: 13.5.2 Chrome: 91.0.4472.164 Node.js: 14.16.0 V8: 9.1.269.39-electron.0 OS: Darwin x64 20.6.0
Name: YAML Id: redhat.vscode-yaml Description: YAML Language Support by Red Hat, with built-in Kubernetes syntax support Version: 1.2.0 Publisher: Red Hat VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=redhat.vscode-yaml
Sorry for the bump. All .yaml
or .yml
files in .github/workflows
folder should use GitHub Workflow schema.
I know it can be set from settings, but I feel that it should do that by default.
The current workaround for now is using this in your .vscode/settings.json
file to set it per workplace or you can set it in your User vscode settings.
{
"yaml.schemas": {
"https://json.schemastore.org/github-workflow.json": [".github/workflows/*.{yml,yaml}"]
}
}
I suppose we can give priority to fileMatch
rules with a path over filename only ones.
Yeah, this is gross. I don't know what "Deployer" is, and having it cause a valid yml file to show as an error is irritating. Grateful to @Hazmi35 for the workaround but a better one would be for it not to happen at all. I never asked VS Code to match against Deployer's schema.
Seeing the same thing, with a k8s deployment yaml named deploy.yaml
. What's irritating is I try to manually select a different schema, like helmfile
that would be more appropriate, and it won't let me. Some rule is requiring deploy.yaml
to be Deployer Recipe
.
can you also exclude files in folders like .gitlab-ci
or ansible
?
whoever thought it would be okay to match only on filenames and to not provide an escape hatch, like: "I know this file type and it's not what you think, it's ansible yaml, I'm allowed to set the name of my ansible yml file to deploy.yml
, am I not? clicks config option" did clearly not think this through, when designing this extension.
I see there is an option yaml.schemas
in the extension settings, but it's not really documented.
the only blurb I can find is this sentence in the README.md
:
yaml.schemas: Helps you associate schemas with files in a glob pattern
yeah, but how? where can I find the list of schemas? what kind of globbing pattern matching is supported?
also, according to a different comment above, this doesn't seem to work if you load the schemas from the schemastore, which is the default.
there are even thirdparty/upstream files in oss playbooks who I just can't rename to use this linter.
Guess I'll need to evaluate other yaml lint options, as this is a long standing issue and it seems nobody is interested in fixing it?
Guess I'll need to evaluate other yaml lint options, as this is a long standing issue and it seems nobody is interested in fixing it?
Seems several other extensions have decided to depend on this extension, e.g. this message when trying to uninstall from VS Code:
Cannot uninstall 'YAML' extension. 'GitHub Actions', 'Kubernetes' and other extension depend on this.
Dependency links for ms-kubernetes-tools.vscode-kubernetes-tools, me-dutour-mathieu.vscode-github-actions.
[edit: typo]
My workaround: I found the schema that match my needs there https://www.schemastore.org/json/ then, in vscode settings.json
"yaml.schemas": {
"https://raw.githubusercontent.com/ansible/schemas/main/f/ansible.json": "deploy.yml"
}
For GitLab users the following worked for me:
"yaml.schemas": {
"https://gitlab.com/gitlab-org/gitlab/-/raw/master/app/assets/javascripts/editor/schema/ci.json": ".gitlab/**/*.yml"
}
I tend to agree with the comment on Sep 14, 2022: - "whoever thought it would be okay to match only on filenames".
Out of the box it's a little presumptuous to look at a filename (anywhere in my project) and assume it's for a specific purpose. I have a deploy.yaml
and it has nothing to do with GitHub or GitLab, and it's present in almost all of my Ansible roles!
For me (VS Code Version: 1.78.2
) I've disabled the Schema Store in settings to solve the problem: -
Is there any chance: -
a) You can be "very specific" about such files in the future, or... b) The Scheme Store is off by default?
Turning the schema store off by default is not an option. Most users of the yaml-language-server
and this extension depend on the schema store functionality and never make any settings changes.
As for the specificity, this extension does not really have any control over the fileMatch
rules entered on the schema store. There is so much YAML in the world that most of the time, we are completely unfamiliar with the YAML file to even PR a fix on the schema store.
I understand this is not ideal for these particular cases, and I wish there were a better way to match files to schemas other than pattern matching. I feel like we are able to provide enough settings for these cases to be satisfied, and if we can provide more, I would be happy to hear the case or better review a PR.
I ended up here trying to pick a filename to avoid an incorrect schema association, but couldn't figure out where the patterns were coming from.
Nothing stood out on https://www.schemastore.org/json/, but after some more searching I found what I think is the source.
Incase it helps anyone else check out https://github.com/SchemaStore/schemastore/blob/master/src/api/json/catalog.json which seems to have a full list.