Front matter closed by "--- ", "---x" or "----": indexed as properties, but not shown as properties, and processFrontMatter adds a second front matter block

Steps to reproduce

  1. Create a note Test.md whose closing --- has three trailing spaces:

    ---
    a: 1
    ---   
    text
    
  2. Open it in Live Preview.

  3. In the developer console run:

    app.metadataCache.getFileCache(app.vault.getAbstractFileByPath('Test.md')).frontmatter
    
  4. Then run (this edits the note):

    await app.fileManager.processFrontMatter(app.vault.getAbstractFileByPath('Test.md'), (fm) => { fm.b = 2; })
    

    and look at the note’s text.

  5. Optionally, compare with what the API’s getFrontMatterInfo(content) (from the obsidian module) returns for the same text, from a plugin.

Did you follow the troubleshooting guide?

Yes (reproduced in the sandbox vault, no community plugins).

Expected result

The metadata cache, the Properties view, processFrontMatter and getFrontMatterInfo agree on whether the note has front matter and where it ends.

Actual result

  • The metadata cache reads front matter { a: 1 }, with a yaml section that ends at the --- and a paragraph text after it. The status bar says “1 property”.

  • Live Preview shows no Properties block: the three lines are shown as raw --- / a: 1 / --- text (screenshot below).

  • processFrontMatter does not see the existing front matter. It adds a new block at the top, so the note becomes:

    ---
    b: 2
    ---
    ---
    a: 1
    ---   
    text
    
  • getFrontMatterInfo returns exists: false: it wants the closing --- to be followed directly by a line break or the end of the file.

The metadata cache takes the first later line that starts with ---, whatever follows on that line:

Closing line Metadata cache getFrontMatterInfo / processFrontMatter Live Preview
--- front matter front matter Properties block
--- + spaces or a tab front matter, then a paragraph none (a second block is added) raw YAML lines, front matter ends at the --- line
---x front matter, then a paragraph x + next line none (a second block is added) raw YAML lines, and the next line text is still styled as front matter
---- front matter, then an empty list item holding the next line none (a second block is added) raw YAML lines, and the next line text is still styled as front matter

The opening --- is strict everywhere: ---␠␠ on the first line gives no front matter (the cache reads a horizontal rule and a heading).

Environment

SYSTEM INFO:
	Obsidian version: 1.14.5
	Installer version: 1.14.4
	Operating system: Windows 11 Pro 10.0.26300
	Login status: not logged in
	Language: en
	Insider build toggle: off
	Live preview: on
	Base theme: adapt to system
	Community theme: none
	Snippets enabled: 0
	Restricted mode: on

RECOMMENDATIONS:
	none

Sandbox vault, no community plugins, default theme and settings.

Additional information

Live Preview of the sample: raw YAML, no Properties block, while the status bar counts 1 property:

Trailing spaces after the closing --- are easy to leave by accident. A related editor bug was fixed in 1.3.2 (Spaces behind frontmatter “—” break the formatting of the note in Edit mode). Today the metadata cache accepts such a closing line, while the Properties view, processFrontMatter and getFrontMatterInfo do not, so anything that edits properties through processFrontMatter (for example a plugin) writes a duplicate front matter block into the note.