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

Uses the wrong schema, even when yaml.schemas is set #397

Closed
1 of 4 tasks
Xunnamius opened this issue Nov 22, 2020 · 29 comments · Fixed by redhat-developer/yaml-language-server#417
Closed
1 of 4 tasks
Labels

Comments

@Xunnamius
Copy link

Xunnamius commented Nov 22, 2020

Describe the bug

wtfbbq

I'm using this extension and the GitHub Actions YAML extension. The last three error messages (using the proper schema) are from that other extension. The erroneous errors above them are from this extension. Disabling the GitHub Actions extension makes those last three (correct, proper) errors disappear, leaving the false errors this extension is reporting.

The problem: this extension thinks my GitHub Actions workflow file is a "deploy php" file and so uses the wrong schema... simply because it has the word "deploy" in its file name. Change the name to build-test-deplox.yml and everything works. I can't make this extension ignore YAML files and I can't force this extension to use the correct schema (on the right, you can see the yaml.schemas setting being completely ignored).

Unfortunately for my .github/dependabot.yml file, I've had to disable this extension for now. Am I doing something wrong here?

Expected Behavior

Use https://json.schemastore.org/github-workflow for build-test-deploy.yml like I told it to

Current Behavior

Uses https://raw.githubusercontent.com/deployphp/deployer/master/src/schema.json instead

Steps to Reproduce

  1. Have .github/workflows/build-test-deploy.yml file in your project
  2. Observe this extension invoke the wrong schema
  3. Try to override the schema for that file (using both full path and simple file name)
  4. Observe this extension continue to invoke the wrong schema

Bonus: replace "https://json.schemastore.org/github-workflow" with "https://json.schemastore.org/github-workflowfdsfdsff"
in yaml.schemas and the extension recognizes that the schema does not exist, so it is receiving the proper schema from settings.json!

Environment

  • Windows
  • Mac
  • Linux
  • other (please specify)
@gorkem
Copy link
Collaborator

gorkem commented Nov 22, 2020

Looks like it is related to redhat-developer/yaml-language-server#250

@c00
Copy link

c00 commented Dec 2, 2020

I'm experiencing the same issue. Slightly related, initially the plugin keeps guessing the wrong schema to apply. But then overwriting its guess with a setting as described in this issue does not work.

@cfbao
Copy link

cfbao commented Dec 3, 2020

Same issue with build_and_deploy.yml

Looks like it is related to redhat-developer/yaml-language-server#250

Want to highlight (from linked issue) that disabling schema store can work around this issue.

@badsyntax
Copy link

Having the same problem, with any github workflow file named '*deploy*'. I'm unable to set the schema with:

"yaml.schemas": {
  "https://json.schemastore.org/github-workflow": "/.githhub/workflows/**/*.yml"
}

@JPinkney
Copy link
Contributor

JPinkney commented Jan 6, 2021

It looks like "/.githhub/workflows/**/*.yml" is spelt wrong, it should probably be "/.github/workflows/**/*.yml". This issue is going to be fixed in the next release

@badsyntax
Copy link

badsyntax commented Jan 6, 2021

@JPinkney good spot! Unfortunately it makes no difference, it's still using the deployphp schema.

[edit] good to know a fix is coming!

@Sytten
Copy link

Sytten commented Feb 10, 2021

FYI @JPinkney I still have issues for some templates

What is weird is that the descriptions are fine, but it still gives an error on the validation.

@libsamek
Copy link

libsamek commented Feb 17, 2021

I'm having a similar issue with GitLab CI configuration file, which contains deploy in its name. I have tried adding gitlab schema into yaml.schemas, but it makes no difference.

EDIT: It would be preferred if yaml.schemas would have higher priority than schema store.

@l3d00m
Copy link

l3d00m commented Feb 21, 2021

image

This still seems to be happening on YAML 0.15.0.

VSCode about output

Version: 1.53.2
Commit: 622cb03f7e070a9670c94bae1a45d78d7181fbd4
Date: 2021-02-11T11:48:44.518Z
Electron: 11.2.1
Chrome: 87.0.4280.141
Node.js: 12.18.3
V8: 8.7.220.31-electron.0
OS: Linux x64 5.10.15-1-MANJARO

@l3d00m
Copy link

l3d00m commented Feb 23, 2021

Interestingly enough, this issue only happens if the action is named deploy.yml. It works perfectly for deploy-dev.yml or my build actions.

@xsalazar
Copy link

xsalazar commented Feb 25, 2021

I just ran into this same issue, and it definitely seems related to not only having deploy in the file name, but also position (maybe relative to symbol-separators?).

docker_deploy.yml

image

deploy.yml

image

deploy_docker.yml

image

@thadeu
Copy link

thadeu commented Mar 24, 2021

I solved problem by renaming file to deployer.yml

Thanks for help!

@joshriverscambia2019
Copy link

@evidolob with the fixed version of yaml-language-server installed, this issue is not resolved. Files named deploy.yml still get the incorrect schema match.

@evidolob
Copy link
Collaborator

evidolob commented Apr 7, 2021

Then we need to get redhat-developer/yaml-language-server#427 merged to fix all issues with file match

@joshmanders
Copy link

Any luck on this? I just ran into it creating a github workflow called deploy.yaml

@ghost
Copy link

ghost commented May 21, 2021

Will there be a release anytime soon? I'm seeing the issue in v0.19.2 in a fresh vscode install. Or is there an easy way to patch this in place?

@fastlorenzo
Copy link

@czmola I've used the following work-around: add the following line on top of the yaml file that fails (usually one with deploy in the name, in my case deploy.yml):

# yaml-language-server: $schema=https://json.schemastore.org/ansible-playbook.json

That should do the trick until it's fixed 😎

@ghost
Copy link

ghost commented May 24, 2021

or the ansible-role-2.9.json schema. if it is a tasklist in a role.

@piotr-cz
Copy link

@fastlorenzo
This doesn't work for me, I'm getting another error:

Unable to load schema from 'd:\xxx\ansible\playbooks\https:\json.schemastore.org\ansible-playbook.json': .

@bermann
Copy link

bermann commented Jul 21, 2021

Any news on this? I'm experiencing the same issue

@evidolob
Copy link
Collaborator

@bermann Are you using latest version if vscode-yaml?
I cannot reproduce this on my side.

@bobba76
Copy link

bobba76 commented Aug 3, 2021

I had the same issue but with another schema.
For me, hammerkit.json was auto chosen when creating my build.yml

The issue was solved by adding this at the top:

# yaml-language-server: $schema=https://json-schema.org/draft-07/schema#

This was the schema that my other yaml file were using.

@cawoodm
Copy link

cawoodm commented Aug 6, 2021

I'm having the same problem with a file called build.yaml. Renaming to build2.yaml solves it.

VSCode: 1.58.2
Azure PIpelines Extension: v1.188.1

@MostefaKamalLala
Copy link

For those who don't know how to set the schema settings with:

"yaml.schemas": {
  "https://json.schemastore.org/github-workflow": "/.github/workflows/**/*.yml"
}

Simply press Ctrl+, in visual code > Extentions > Yaml > Edit in settings.json right after Yaml: completion

johnbillion added a commit to johnbillion/user-switching that referenced this issue Nov 16, 2021
bleach31 pushed a commit to bleach31/vscode-yaml that referenced this issue Jan 25, 2022
* feat: add multiple schema deletions

* fix: typing MODIFICATION_ACTIONS.deleteAll

Co-authored-by: Petr Spacek <p-spacek@email.cz>
@lazarillo
Copy link

For those who don't know how to set the schema settings with:

"yaml.schemas": {
  "https://json.schemastore.org/github-workflow": "/.github/workflows/**/*.yml"
}

Simply press Ctrl+, in visual code > Extentions > Yaml > Edit in settings.json right after Yaml: completion

This seems like exactly what I should need, since the proper schema was not being found. But I tried it and it did not help.
In the screenshot below, I have hovered over a variable in the env section. It should expect a list of any key-value pairs:

VS Code GitHub Actions Syntax Highlighting Issue

I then double checked json.schemastore.org/github-workflow and it says that it should work, but it still doesn't. The relevant snippet:

    "env": {
      "$comment": "https://docs.github.com/en/actions/learn-github-actions/environment-variables",
      "description": "To set custom environment variables, you need to specify the variables in the workflow file. You can define environment variables for a step, job, or entire workflow using the jobs.<job_id>.steps[*].env, jobs.<job_id>.env, and env keywords. For more information, see https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idstepsenv",
      "oneOf": [
        {
          "type": "object",
          "additionalProperties": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "number"
              },
              {
                "type": "boolean"
              }
            ]
          },
          "minProperties": 1
        },
        {
          "$ref": "#/definitions/expressionSyntax",
          "$comment": "https://docs.github.com/en/actions/learn-github-actions/expressions#fromjson",
          "pattern": "^\\$\\{\\{\\s*fromJSON\\(.*\\)\\s*\\}\\}$"
        }
      ]
    },

I'm not sure what I'm doing wrong. Is no one else having this syntax highlighting problem?

For now, I have just turned it off via:

    "files.associations": {
        "/.github/workflows/**/*.yml": "plaintext"
    },

in my settings.json file.

@douglaswth
Copy link

@lazarillo it looks like the latest version has introduced some issues with how it interprets the GitHub Workflow schema: #691.

@Wiiki0807
Copy link

I had the same issue but with another schema. For me, hammerkit.json was auto chosen when creating my build.yml

The issue was solved by adding this at the top:

# yaml-language-server: $schema=https://json-schema.org/draft-07/schema#

This was the schema that my other yaml file were using.

This work for me, thanks for tip. @bobba76

sha-cmd added a commit to sha-cmd/Dyadic that referenced this issue May 6, 2022
@hdodov
Copy link

hdodov commented Jun 14, 2022

I also experience strange behavior on Windows with VS Code 1.67.2 and redhat.vscode-yaml 1.8.0.

A file site/blueprints/site.yml for some reason gets validated with the Ansible Playbook schema, turning everything red. I checked all settings (folder, workspace, user) and I have nothing set. Restarting VS Code doesn't help either. The only solution seems to be "yaml.validate": false...

@kaleocheng
Copy link

kaleocheng commented Jun 15, 2022

This doesn't work for me, I'm getting another error:

Unable to load schema from 'd:\xxx\ansible\playbooks\https:\json.schemastore.org\ansible-playbook.json': .

@piotr-cz for Ansible, it's using this now https://raw.githubusercontent.com/ansible-community/schemas/main/f/ansible.json

# yaml-language-server: $schema=https://raw.githubusercontent.com/ansible-community/schemas/main/f/ansible.json

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

Successfully merging a pull request may close this issue.