Fix write doubling frontmatter when content already has a ---…#206
Merged
Conversation
…PRD-6997) (#1964)
* fix(open-knowledge): merge frontmatter instead of doubling on write (PRD-6997)
write({ document: { content, frontmatter } }) stacked two frontmatter
blocks when content already opened with a --- block AND a frontmatter
param was supplied. composeWithFrontmatter now strips the embedded block,
merges it with the param (param wins per key, embedded-only keys survive),
and emits a single block. A malformed embedded block is rejected with a
teaching error rather than silently doubled.
* address review: drop orphaned dropEmpties, add null-clear test
PR #1964 review (claude): composeWithFrontmatter switched from dropEmpties
to mergePatch, leaving dropEmpties with zero production callers and a stale
'load-bearing at submit time' docstring. mergePatch already encapsulates the
empty-dropping via isFrontmatterValueEmpty, so remove dropEmpties + its tests.
Add a null-clear case to write.test.ts (RFC 7396 delete sentinel) alongside
the existing empty-string case.
* test: cover embedded-block strip when param clears its only key
PR #1964 re-review (claude): the yamlBody === '' early-exit was only
exercised via the plain-body branch; add the embedded-block-present case
where the param clears every embedded key so the fence is stripped too.
---------
GitOrigin-RevId: 9fc42b83356732e0147bd9cfac00652a5a50baa0
Contributor
There was a problem hiding this comment.
Automated approval from agents-private public-mirror-sync (run: https://github.com/inkeep/agents-private/actions/runs/27783656634). Source of truth is the monorepo; direct edits on inkeep/open-knowledge are overwritten on next sync.
|
|
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.
Fix
writedoubling frontmatter whencontentalready has a---block and afrontmatterparam is also supplied. The two are now merged into a single block (thefrontmatterparam wins per key, embedded-only keys survive) instead of stacking a second block on disk. A malformed embedded block is rejected with a clear error rather than silently doubled.