Skip to content

Fix write doubling frontmatter when content already has a ---#206

Merged
inkeep-oss-sync[bot] merged 1 commit into
mainfrom
copybara/sync
Jun 18, 2026
Merged

Fix write doubling frontmatter when content already has a ---#206
inkeep-oss-sync[bot] merged 1 commit into
mainfrom
copybara/sync

Conversation

@inkeep-oss-sync

Copy link
Copy Markdown
Contributor

Fix write doubling frontmatter when content already has a --- block and a frontmatter param is also supplied. The two are now merged into a single block (the frontmatter param 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.

…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

@inkeep-internal-ci inkeep-internal-ci Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

@inkeep-oss-sync inkeep-oss-sync Bot merged commit 659a6a4 into main Jun 18, 2026
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@inkeep-oss-sync inkeep-oss-sync Bot deleted the copybara/sync branch June 18, 2026 19:21
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.

2 participants