Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KEY_OVER_1024_CHARS error with large indented blocks of comments #413

Closed
fluggo opened this issue Sep 30, 2022 · 5 comments
Closed

KEY_OVER_1024_CHARS error with large indented blocks of comments #413

fluggo opened this issue Sep 30, 2022 · 5 comments
Labels
bug Something isn't working

Comments

@fluggo
Copy link

fluggo commented Sep 30, 2022

Describe the bug
If there's a large block of comments hanging indented under a key, that can trigger an error suggesting that the next key indicator is too far away.

To Reproduce

const comment = `# Test comment
owners:
  # Test comment
  business:
    - email: great.googly@fortitude.com
      name: Moogly
    - distributionList: HopsNBops@easterbunny.org

  # Another comment, large block of text, large block of text, large block of text
  # Another comment, large block of text, large block of text, large block of text
  # Another comment, large block of text, large block of text, large block of text
  # Another comment, large block of text, large block of text, large block of text
  # Another comment, large block of text, large block of text, large block of text

# Large block of text, large block of text, large block of text, large block of text, large block of text,
# large block of text, large block of text, large block of text, large block of text, large block of text,
# large block of text, large block of text, large block of text, large block of text, large block of text,
# large block of text, large block of text, large block of text, large block of text, large block of text,
# large block of text, large block of text, large block of text, large block of text, large block of text,
# large block of text, large block of text, large block of text, large block of text, large block of text,
# large block of text, large block of text, large block of text, large block of text, large block of text,
stage: one
`;

console.log(yaml.parse(comment));

The script produces the error:

YAMLParseError: The : indicator must be at most 1024 chars after the start of an implicit block mapping key at line 22, column 1:

# large block of text, large block of text, large block of text, large block of…
stage: one
^^^^^

Removing the indent from the first block of comments works around the error.

Expected behaviour
The text is valid YAML, it should be parsed, no matter how many comments there are or whether they're indented.

Versions (please complete the following information):

  • Environment: Node.js 16.15.1
  • yaml: 2.1.1
@fluggo fluggo added the bug Something isn't working label Sep 30, 2022
@eemeli
Copy link
Owner

eemeli commented Oct 2, 2022

There was a bug in updating the offset during composition for empty mapping values with trailing comments. Thank you for reporting this!

Fixed version released as v2.1.2.

@eemeli eemeli closed this as completed Oct 2, 2022
@fluggo
Copy link
Author

fluggo commented Oct 4, 2022

Might check it against my sample again. I don't think the main bug has been fixed yet.

@eemeli
Copy link
Owner

eemeli commented Oct 5, 2022

Bother; you're right. I'd found first a minimal example that appeared to trigger the same error, and solved against that only.

@eemeli
Copy link
Owner

eemeli commented Oct 5, 2022

New fix released as 2.1.3.

@fluggo Please let me know if that actually fixes this?

@eemeli
Copy link
Owner

eemeli commented Oct 26, 2022

Closing as presumably fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants