yaml-language-server icon indicating copy to clipboard operation
yaml-language-server copied to clipboard

Missing required property value reported as type error

Open gee4vee opened this issue 2 years ago • 2 comments

Describe the bug

A missing required property is reported as a type error.

image

Incorrect type. Expected "string".

image

This is likely due to the YAML to JSON conversion which inserts a null where the yaml has no value.

Expected Behavior

The error should be reported as a missing value.

Current Behavior

The error is reported as at type error.

Steps to Reproduce

  1. Copy and open this blueprint in vscode where the yaml-language-server is installed.
  2. Add this yaml-language-server schema declaration: https://raw.githubusercontent.com/Cloud-Schematics/vscode-blueprint-schema/master/blueprint_schema.json
  3. Remove the value of the name of one of the modules.

Environment

  • [x] Windows
  • [x] Mac
  • [x] Linux
  • [ ] other (please specify)

gee4vee avatar Feb 17 '23 20:02 gee4vee

I do not think the current behaviour is incorrect in this case. In YAML, empty values are recognized as null . So the parser basically reports the value as null, and the schema validator reports that the schema is expecting a string.

This can probably be resolved on the referenced schema by defining the type of the property as name : { "type": ["string", "null"] }

gorkem avatar Mar 26 '23 00:03 gorkem