fix(frontmatter): silence yaml collection-key warning on template notes#60
Merged
Merged
Conversation
Reading a note whose frontmatter contains a Templater placeholder
(`date: {{date}}`) parses to a collection-valued key, which the `yaml`
library reports via `process.emitWarning` — once per such note on every
scan, spamming the MCP stderr log without affecting behavior.
Pass `logLevel: 'error'` to `parseYaml` in `splitFrontmatter`: warnings
are suppressed while genuinely malformed YAML still throws and is handled
by the existing catch. The parsed result is unchanged; only the log noise
is gone.
Co-Authored-By: Claude Opus 4.7 <[email protected]>
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.
What
Reading a note whose frontmatter contains a Templater placeholder — e.g.
date: {{date}}— no longer spams stderr with:Why
{{date}}is valid YAML flow syntax that parses to a collection-valued key (a map used as a map key). Whenyamlmaterializes that to a plain JS object it can't keep an object as a key, so it emits the warning via Node'sprocess.emitWarning— once per such note, on every read/scan. Harmless to behavior, but it clutters the MCP server's stderr log.Reported from a 12.1.0 → 13.0.0 field upgrade: fires on every template note whose frontmatter carries a
{{…}}placeholder.Fix
Pass
logLevel: 'error'toparseYamlinsplitFrontmatter(src/lib/obsidian/frontmatter.ts). This gates yaml's warnings while still throwing on genuinely malformed YAML, which the existingtry/catchalready handles. The parsed result is byte-for-byte unchanged — only the log noise is gone.Not changed:
mapAsMap: true(the library's own suggestion) would turn every frontmatter mapping into a JSMap, breaking the tool contract — rejected. TheparseDocumentmutate path infs-vault-provider.tsre-serializes viatoString()and never hitstoJS()for these notes, so it doesn't emit the warning.Test
Added a
splitFrontmattercase that spies onprocess.emitWarningwhile parsingdate: {{date}}frontmatter and asserts zero calls (red before the fix, green after), plus that parsing still succeeds.npm test(819 passed),npm run lint,npm run typecheckall green.🤖 Generated with Claude Code