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

Hammerkit yaml schema picked up instead of Github actions #565

Closed
1 of 4 tasks
andig opened this issue Jul 25, 2021 · 8 comments · Fixed by #643
Closed
1 of 4 tasks

Hammerkit yaml schema picked up instead of Github actions #565

andig opened this issue Jul 25, 2021 · 8 comments · Fixed by #643
Assignees
Milestone

Comments

@andig
Copy link

andig commented Jul 25, 2021

Describe the bug

I have yaml.schemaStore.enable active and work with github actions (yaml files in .github/workflows. Editing build.yaml I see error indicators.

Expected Behavior

No errors as yaml validated based on https://json.schemastore.org/github-action.json

Current Behavior

Errors relating to https://json.schemastore.org/hammerkit.json

Steps to Reproduce

Not really sure. This may be a problem with any of the schema definitions rather than this plugin, but I couldn't figure it out.

Environment

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

Same issue. This wasn't happening a few months ago.

@HarikrishnanBalagopal
Copy link

Going to https://schemastore.org/ I get a certifacte error saying:
image
Does that have anything to do with this?

NOTE: the exact url has the correct certificate https://json.schemastore.org/github-action.json

@HarikrishnanBalagopal
Copy link

HarikrishnanBalagopal commented Jul 30, 2021

@andig Also the correct schema for Github workflows is this https://json.schemastore.org/github-workflow.json

For now we can workaround this issue by putting this comment at the top of the yaml file

# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json

@ariasuni
Copy link

This issue happens on Linux too. On my side, the plugins says it’s using both github-actions.json and hammerkit.json.

My solution was to put, in settings.json:

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

@andig
Copy link
Author

andig commented Aug 15, 2021

I‘m still confused as to why it would be doing this?

@evidolob evidolob added this to the 0.23.0 milestone Aug 18, 2021
@ariasuni
Copy link

ariasuni commented Aug 20, 2021

JSON Schema Store’s API returns a list of schema with their fileMatch (source), that vscode-yaml uses to determine which schema to apply to which file.

If we look into it:

    {
      "name": "Hammerkit YAML Schema",
      "description": "JSON Schema for hammerkit files.",
      "fileMatch": [
        "build.yaml",
        "build.yml"
      ],
      "url": "https://json.schemastore.org/hammerkit.json"
    }

and

    {
      "name": "GitHub Workflow",
      "description": "YAML schema for GitHub Workflow",
      "fileMatch": [
        ".github/workflows/**.yml",
        ".github/workflows/**.yaml"
      ],
      "url": "https://json.schemastore.org/github-workflow.json"
    },

There’s no clear way to determine which one should be used, even though it’s obvious for us human.

This extension could:

  • Add a special case in their code for GitHub actions, or find some kind of heuristic (e.g. a fileMatch with a / has priority over a fileMatch that does not, or see if applying one schema leads to more error than the other)
  • Allow the user to chose which one to use with CodeLens, since it’s already able to display the two schema used using this, instead of using two schemas at the same time, it’s just never what we want.

@evidolob
Copy link
Collaborator

@ariasuni You are right.

Allow the user to chose which one to use with CodeLens, since it’s already able to display the two schema used using this, instead of using two schemas at the same time, it’s just never what we want.

That how I plan to fix this.

@evidolob evidolob self-assigned this Sep 16, 2021
@evidolob evidolob modified the milestones: 0.23.0, 0.24.0 Sep 29, 2021
@evidolob evidolob modified the milestones: 1.1.0, 1.2.0 Oct 28, 2021
@evidolob evidolob modified the milestones: 1.2.0, 1.3.0 Nov 10, 2021
dkfellows added a commit to SpiNNakerManchester/JavaSpiNNaker that referenced this issue Feb 1, 2022
Explanation is in redhat-developer/vscode-yaml#565 (and the fundamental
problem is ambiguity between schema selectors resulting in the wrong
option being chosen; the workaround is to force an override)
@nomicode
Copy link

It should be possible to determine which schema to use if you compare how specific the fileMatch key is. I would measure specificity by splitting the value on path separators (/). The more path components, the more specific the match is. More specific matches take precedence over less specific matches.

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

Successfully merging a pull request may close this issue.

5 participants