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

example fails yaml validation #746

Open
2 of 5 tasks
boneskull opened this issue Jan 17, 2024 · 9 comments
Open
2 of 5 tasks

example fails yaml validation #746

boneskull opened this issue Jan 17, 2024 · 9 comments
Labels
bug Something isn't working

Comments

@boneskull
Copy link

Description:

The example in the README fails YAML schema validation in VSCode

Action version:

v5.0.0

Platform:

  • Ubuntu
  • macOS
  • Windows

Runner type:

  • Hosted
  • Self-hosted

Repro steps:

  1. Create a new labeler.yml in .github
  2. Paste this (from the example):
    # Add 'source' label to any change to src files within the source dir EXCEPT for the docs sub-folder
    source:
    - all:
      - changed-files:
        - any-glob-to-any-file: 'src/**/*'
        - all-globs-to-all-files: '!src/docs/*'
  3. See error: image image

Expected behavior:
No validation error

Actual behavior:
See screenshots

@HarithaVattikuti
Copy link
Contributor

Hello @boneskull
Thank you for creating this issue. We will investigate it and get back to you as soon as we have some feedback.

@CRC-Mismatch
Copy link

CRC-Mismatch commented Jan 31, 2024

This seems to be related to the schema published on https://json.schemastore.org/pull-request-labeler.json being out-of-date.

I'm not sure if that's the same one used by VSCode, but I can see the same validation failure in current Jetbrains IDEs, and they automatically fetch the schemas from there.

@boneskull
Copy link
Author

To fix that, a PR should be created in the schemastore repo

@QuLogic
Copy link

QuLogic commented Feb 7, 2024

I've written an updated schema that should be available already: https://json.schemastore.org/pull-request-labeler-5.json

I don't know whether VSCode actually uses those schemas though.

@hyperupcall
Copy link

I don't know whether VSCode actually uses those schemas though

VSCode itself won't with YAML files, but will do so with an extension, like the Red Hat YAML Extension

@CRC-Mismatch
Copy link

CRC-Mismatch commented May 29, 2024

@QuLogic I think there's still something wrong with that schema... Or maybe with JetBrains' YAML validator. Either way, it's warning that the shorthand <label>: [ { changed-files: [ { ... } ] } ] way is wrong (I've shortened it, but it's using multi-line blocks in my case...
image

At least the verbose syntax works OK now (but too bad that I have to add a custom schema mapping to every project in order to use your schema 🥹 )

About VSCode, by itself it only validates the basic YAML syntax (AFAICR, maybe not even that), but it automatically offers "There are extensions in the marketplace for YAML!" the first time you open up one, and the top results will probably all validate using SchemaStore anyway 🤷‍♂️

@QuLogic
Copy link

QuLogic commented May 29, 2024

That form is part of the tests, so if it's failing, it's not due to the schema.

@spock-yh
Copy link

This behavior seems to be a quirk of Intellij. It is solved if in the JSON schema one replaces oneOf with anyOf in the requirements of the Match object schema. Instead of:

      "oneOf": [
        { "required": ["changed-files"] },
        { "required": ["base-branch"] },
        { "required": ["head-branch"] }
      ],

Use:

      "anyOf": [
        { "required": ["changed-files"] },
        { "required": ["base-branch"] },
        { "required": ["head-branch"] }
      ],

There seem to be similar issues with oneOf with some validators, e.g. RicoSuter/NJsonSchema#1596.

Attaching a schema file that works in Intellij, you can add a schema mapping locally until this gets fixed in schemastore.org or in the validator.
pull-request-labeler-5-schema.json

@freeformz
Copy link

FWIW: This is a PITA

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants