vscode-yaml: Uses the wrong schema, even when yaml.schemas is set

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)

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 40
  • Comments: 29 (1 by maintainers)

Commits related to this issue

Most upvoted comments

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

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

@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 😎

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

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"
}

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.

@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.

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.

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

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.

@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': .

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.

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

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

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

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