question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Schema validation reports errors in valid YAML document

See original GitHub issue

I have rather complex JSON schema with which YAML plugin doesn’t work correctly. It reports errors in valid YAML document. But when I use this schema with equivalent JSON document it works correctly.

I tried to simplify the schema and narrow the problem but it is still long and complex because the problem is in some combination of schema constructs.

I have vscode-yaml 0.0.4 with VSCode insider build (see bellow).

Here is the YAML document which doesn’t work correctly:

aaa:
  type: TypeA
  properties:
    propertyA: { stringArray: [ "abcd"] }

Here is JSON document which works:

{
    "$schema": "./test.schema.json",
    "aaa": {
        "type": "TypeA",
        "properties": {
            "propertyA": {
                "stringArray": ["abcd"]
            }
        }
    }
}

Here is test.schema.json schema:

{
  "$schema": "http://json-schema.org/schema#",
  "type": "object",
  "properties": {
    "aaa": {
      "oneOf": [
        {
          "allOf": [
            {
              "properties": {
                "type": {
                  "enum": [
                    "TypeA"
                  ]
                },
                "properties": {
                  "type": "object",
                  "properties": {
                    "propertyA": {
                      "$ref": "#/definitions/commonStructures",
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "propertyA"
                  ],
                  "additionalProperties": true
                }
              },
              "required": [
                "type"
              ]
            },
            {
              "$ref": "#/definitions/commonProperties"
            }
          ]
        },
        {
          "allOf": [
            {
              "properties": {
                "type": {
                  "enum": [
                    "TypeB"
                  ]
                },
                "properties": {
                  "type": "object",
                  "properties": {
                    "propertyB": {
                      "$ref": "#/definitions/commonStructures",
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "propertyB"
                  ],
                  "additionalProperties": true
                }
              },
              "required": [
                "type"
              ]
            },
            {
              "$ref": "#/definitions/commonProperties"
            }
          ]
        }
      ]
    }
  },
  "required": [
    "aaa"
  ],
  "additionalProperties": true,
  "definitions": {
    "commonProperties": {
      "type": "object",
      "properties": {
        "commonProperty": {
          "type": "string"
        }
      }
    },
    "commonStructures": {
      "type": "object",
      "properties": {
        "stringArray": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "minItems": 1
        }
      },
      "additionalProperties": false
    }
  }
}
  • VSCode Version: Code - Insiders 1.18.0-insider (2ab10d50163f008ada9a4aa215de8c884857ce99, 2017-11-01T05:19:21.302Z)
  • OS Version: Windows_NT x64 10.0.16299
  • Extensions:
Extension Author (truncated) Version
vscode-yaml red 0.0.4

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
JPinkneycommented, Nov 9, 2017

I believe this is the same issue. I have a fix for it we just need to release the extension again for the update!

1reaction
JPinkneycommented, Nov 2, 2017

I’ve narrowed this down to a regression in redhat-developer/yaml-language-server@2a8456a7e2e319aece0f9d05e5af087450cedf63 inside the jsonParser. I’m currently working on fixing this!

Read more comments on GitHub >

github_iconTop Results From Across the Web

YAML Schema Validation reports incorrect errors for if conditions
For an Azure Devops pipeline where there is a valid condition (e.g. it runs correctly) it is reporting a validation error in the...
Read more >
YAML Schemas: Validating Data without Writing Code
Does it report an error to the user? Is the behaviour undefined? Does it crash? The YAML data model has strong, implicit typing....
Read more >
Code Inspections in YAML | JetBrains Rider Documentation
Reports inconsistencies between a YAML file and a JSON Schema if the schema is specified. Scheme example: { "properties": { "SomeNumberProperty" ...
Read more >
Understanding schema errors | HESA
The schema is defined by the XSD. Schema errors occur where there is a problem with the structure or order of the file,...
Read more >
Resolve template validation or template format errors in ... - AWS
For "JSON not well-formed" or "YAML not well-formed" errors, see the Validate template syntax section. · For "Unresolved resource dependencies [ ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found