redhat-developer / redhat-developer/vscode-yaml

Custom tag validation doesn't override default validation

Open
#501 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
829
Forks
260
Avg merge
5h 43m
Merged PRs (30d)
1

Description

Describe the bug

As mentioned here https://github.com/SchemaStore/schemastore/issues/1476#issuecomment-833755700 , it turns out the default validation for .gitlab-ci.yml type is taken in priority to the validation I want to set with

"yaml.customTags": [
        "!reference sequence"
    ],

in the settings of the extension.

Message from issue mentionned above:

From what I understand there is a rule conflict with this custom tag.

For the script attribute, without using "!reference", validation says "The script attribute can be an array of string"
For the script attribute, with "!reference" (configured with "sequence" type), validation says "The script attribute can be an array of string"
--> so for script attribute, both cases are valid

For the rules attribute without using "!reference", validation says "The rules attribute must be an array of objects"
For the rules attribute, with "!reference" (configured with "sequence" type), validation says "The rules attribute can be an array of string"
--> so for rules attribute, only the first case works
--> It turns out that the validation rule we set up for the custom "!reference" tag is overridden by the default validation rule

Maybe we have to make sure that the validation for custom tag overrides the default one.

Expected Behavior

When setting "sequence" for a custom tag, I should be able to set a sequence of strings for the custom tag, and the default validation of the current attribute should be ignored.

Current Behavior

The content of the custom tag sequence is marked as "problem" because the default validation for the current attribute doesn't allow to have an array of strings as value.

Steps to Reproduce

  1. Create a .gitlab-ci.yml file with a job containing "rules" attribute . Reproduce setup here https://github.com/SchemaStore/schemastore/issues/1476#issuecomment-829465538 , but put rules: !reference [.conditions, manual_on_develop_and_hotfix] instead of
script:
    - !reference [.conditions, .manual_on_develop_and_hotfix]
  1. Observe problem
  2. Apply fix https://github.com/SchemaStore/schemastore/issues/1476#issuecomment-833759647
  3. Observe problem has disappeared

Environment

  • Windows
  • Mac
  • Linux
  • other (please specify)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the reported case in a .gitlab-ci.yml file using rules: !reference and the yaml.customTags setting configured as !reference sequence. Compare validation with and without the custom tag, and consider the issue complete when the custom tag accepts the sequence of strings without the default attribute validation marking it as a problem.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript, yaml
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.