Skip to content

Numbers in comments #922

@alexvoss

Description

@alexvoss

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
  • Mac (and vim or VSCode)
  • Linux
  • other (please specify)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions