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

Numbers in comments

Open alexvoss opened this issue 1 year ago • 1 comments

Describe the bug

I am using yaml-language-server via RedHat's VSCode plugin and whenever I put a number (like '7') into a comment that occurs at the beginning of the document, the schema does not get loaded:

image

The error also occurs when I have the comment above the document start line ('---') or when I add a %YAML directive. See this discussion of the behavior in the VSCode plugin.

This is not an issue with the plugin since I can reproduce the issue with vim:

image

Expected Behavior

The schema should be loaded and used to validate the YAML file.

Current Behavior

Instead, I get the error message Unable to parse content from '[absolute path]/testSchema.yaml': Parse error at offset 0.

Steps to Reproduce

  1. Create this schema file:
---
# a comment - that seems to work unless we add a number 123
title: Learning JSON/YAML schema 
type: object
properties:
  id: 
    type: string
  1. Create this YAML file in the same directory:
# yaml-language-server: $schema=./testSchema.yaml
---
id: "123"
description: "a short description"

Environment

  • [ ] Windows
  • [X] Mac (and vim or VSCode)
  • [ ] Linux
  • [ ] other (please specify)

alexvoss avatar Sep 10 '23 15:09 alexvoss

One more observation: the problem disappears when I add a modeline. Hope this helps.

# yaml-language-server: $schema=http://json-schema.org/draft-07/schema

alexvoss avatar Sep 12 '23 15:09 alexvoss