Skip to content

Recursive anchors crash extension #897

@lemonyte

Description

@lemonyte

Describe the bug

When using a recursive anchor, the extension outputs the following error and linting/validation stops working.

Request textDocument/foldingRange failed.
  Message: Request textDocument/foldingRange failed with message: Maximum call stack size exceeded
  Code: -32603

YAML:

# Arbitrary schema
# yaml-language-server: $schema=https://json.schemastore.org/github-action.json
&root
prop:
  sub: *root

The yaml package and Ajv have no problem parsing and applying the recursive anchor.

Output of YAML.parse():

<ref *1> { prop: { sub: [Circular *1] } }

Expected Behavior

Linting and validation should continue working.

Current Behavior

The extension crashes with the error indicated above.

Without recursive anchor, works as intended:
image

With recursive anchor, does not work:
image

Steps to Reproduce

  1. Create a new YAML file
  2. Paste the provided example content, and indicate an arbitrary schema to try validating the content
  3. Remove the recursive *root reference, and notice that validation works as intended
  4. Add the *root reference back, and notice that the extension stops working

Environment

  • Windows
  • Mac
  • Linux
  • other (please specify)

Notes

I may be able to open a PR fixing this if that becomes necessary.

If this issue should be under https://github.com/redhat-developer/yaml-language-server please transfer it.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions