Repository navigation
Fix parser accepting falsy non-mapping frontmatter - #38
Open
sumitsharma01 wants to merge 1 commit into
Open
sumitsharma01 wants to merge 1 commit into
sumitsharma01 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
OKFDocument.parseexpects YAML frontmatter to be a mapping. However, it currently acceptsfalse,0,[], and''and converts them into an empty mapping instead of raising an error.This happens because the parser uses
yaml.load(...) or {}. These values are falsy in Python, so they are replaced with{}before the mapping check runs. Other non-mapping values already raiseOKFDocumentError.The fix replaces only
Nonewith an empty mapping. This preserves the existing behavior for empty, comment-only, and null frontmatter, while allowing the mapping check to reject invalid scalar and sequence values consistently.Added parameterized tests for the invalid values and for the empty frontmatter cases. Four regression cases failed before the fix. With the fix applied, all 50 tests pass using
.venv/bin/pytest, andgit diff --checkpasses.