Skip to content

Conversation

@thevilledev
Copy link
Contributor

The YAML parser was incorrectly splitting documents with version directives (e.g. '%YAML 1.1') by treating the first '---' marker as a document separator. This caused the version directive to be separated from its document, resulting in parsing errors. Fixed document separation logic to keep version directive with its document.

Added test cases for various YAML scenarios and improved test coverage.

Fixes #998

The YAML parser was incorrectly splitting documents with version directives
(e.g. '%YAML 1.1') by treating the first '---' marker as a document separator.
This caused the version directive to be separated from its document,
resulting in parsing errors. Fixed document separation logic to keep
version directive with its document.

Added test cases for various YAML scenarios and improved test coverage.

Signed-off-by: Ville Vesilehto <[email protected]>
Copy link
Member

@anderseknert anderseknert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great to me! Left a small suggetion, but looks good to merge for me.

Based on PR feedback:

- use byte slices instead of string concat
- set common byte sequences as vars

Signed-off-by: Ville Vesilehto <[email protected]>
@anderseknert anderseknert merged commit 3096ca7 into open-policy-agent:master Jan 31, 2025
7 checks passed
@thevilledev thevilledev deleted the fix/yaml-preamble-multidoc branch January 31, 2025 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Conftest fails on YAMLs with version

2 participants