redhat-developer / redhat-developer/vscode-yaml

Possible bug in allOf processing

Open
#1,074 1 comment 1 reaction 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

vscode linter shows an incorrect message of "Property x is not allowed" if the property is defined in an object referenced in an allOf statement

Expected Behavior

o3:
  p1: www
  p2: 2
  p3: false

validator shouldn't show errors (Property p1 is not allowed, Property p2 is not allowed, Property p3 is not allowed)

for this schema:

{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "type": "object",
    "additionalProperties": false,
    "definitions": {
        "o1": {
            "type": "object",
            "properties": {
                "p1": {
                    "type": "string"
                },
                "p2": {
                    "type": "number"
                }
            },
            "required": [
                "p1",
                "p2"
            ]
        },
        "o2": {
            "type": "object",
            "properties": {
                "p3": {
                    "type": "boolean"
                }
            },
            "required": [
                "p3"
            ]
        }
    },
    "properties": {
        "o3": {
            "type": "object",
            "allOf": [
                {
                    "$ref": "#/definitions/o1"
                },
                {
                    "$ref": "#/definitions/o2"
                }
            ]
        }
    },
    "required": [
        "o3"
    ]
}

Current Behavior

The validator shows the manifest as incorrect.

Steps to Reproduce

  1. Define the schema an associate it to the manifest a.test.yaml
  2. fill the manifest with the above manifest example
  3. check the errors

Environment

  • Windows
  • Mac
  • [X ] 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

Reproduce the report using the supplied draft-07 schema and manifest in a.test.yaml, then trace the VS Code YAML validator's handling of allOf and $ref. Done means the example manifest produces no incorrect "Property ... is not allowed" errors for p1, p2, or p3.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 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.