vscode-yaml icon indicating copy to clipboard operation
vscode-yaml copied to clipboard

Failure to properly interpret github workflows schema

Open ssbarnea opened this issue 2 years ago • 5 comments

Describe the bug

I discovered a bug in yaml language server which makes it confused and report a false positive with current github-workflows schemas, even if these schemas are valid, tested (ajv) to ensure they accept that values.

on:
  create:
    tags:  # <-- this is valid but extension believes create should only allow arrays
    - "**"

Schema: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/github-workflow.json

postive-test file for that schema that includes the our bug https://github.com/SchemaStore/schemastore/blob/master/src/test/github-workflow/918.json#L5

Expected Behavior

Pass validating with schemas that are already tested.

Current Behavior

Property tags is not allowed. is reported when it should not be.

Steps to Reproduce

  1. create a file under .github/workflows/sample.yml
  2. put the snipped above in it
  3. check for false positive result

ssbarnea avatar Feb 04 '22 10:02 ssbarnea

Are you still able to reproduce the issue? I do not seem to get the same problem. I am on vscode-yaml 1.4.0

gorkem avatar Feb 21 '22 00:02 gorkem

I was trying to reproduce the bug again with the newer version but I got stuck on another new issue, it reports "Multiple JSON Schemas..." and I am unable to deselect them in any way.

I even removed the local schema patterns and reloaded the window but it still does the same thing. I have no idea on how to make it use a single schema file. I guess that might be a regression introduced by the new version of yaml extension or vscode update.

ssbarnea avatar Feb 22 '22 15:02 ssbarnea

I figured it out where the double assignment came from (user config and workspace config, still disabling or unselecting from the dropdown not possible).

So basically, I removed local schemas assignments and reset the schema cache and I was able to reproduce the issue. tags still gets highlighted as not allowed, even if schema allows it. There is even a test that is passing at https://github.com/SchemaStore/schemastore/blob/master/src/test/github-workflow/918.json with their schema verifications, but our vscode-yaml reports that as not accepted.

on:
  create:
    tags:
      - "**"

ssbarnea avatar Feb 22 '22 15:02 ssbarnea

I can confirm that another schema that is incorrectly loaded is https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/prettierrc.json --- any prettier config reports as broken, even if is correct. Another case of anyOf not working as expected.

ssbarnea avatar Mar 04 '22 10:03 ssbarnea

This but still reproduces with version 1.6.0, I am also adding some test files for these schemas and they are passing schema testing. Still, our extension gets totally confused by the use of anyOf.

See https://github.com/SchemaStore/schemastore/pull/2162/files

ssbarnea avatar Apr 04 '22 08:04 ssbarnea

Do you have any updates on this bug. Yaml extension doesn't work with GitHub Workflows

oleksandr-ivanov-ah avatar Nov 19 '22 18:11 oleksandr-ivanov-ah

I have this issue when "yaml.disableAdditionalProperties": true. If i set "yaml.disableAdditionalProperties": false, yaml extension works as expected

oleksandr-ivanov-ah avatar Nov 19 '22 19:11 oleksandr-ivanov-ah