Skip to content

fix(memory-wiki): wiki_apply errors when another page has bad frontmatter#96177

Closed
ZacharyYW wants to merge 1 commit into
openclaw:mainfrom
ZacharyYW:fix/memory-wiki-frontmatter-yaml-crash-96125
Closed

fix(memory-wiki): wiki_apply errors when another page has bad frontmatter#96177
ZacharyYW wants to merge 1 commit into
openclaw:mainfrom
ZacharyYW:fix/memory-wiki-frontmatter-yaml-crash-96125

Conversation

@ZacharyYW

Copy link
Copy Markdown
Contributor

Closes: #96125

What Problem This Solves

Fixes an issue where wiki_apply and wiki_lint would report a YAML parse error and look like they failed, even though the requested write or lint had already completed. The error actually came from a completely unrelated page elsewhere in the vault whose frontmatter happened to contain YAML that couldn't be parsed (in the reported case, a sourceIds list item with an inline : inside bold markdown text, which YAML tried to read as a nested key-value pair).

Why This Change Was Made

Both tools call compileMemoryWikiVault() after their own work to refresh vault-wide indexes, and that recompile reads and parses every page's frontmatter. toWikiPageSummary() had no error handling around the YAML parse, so one bad page anywhere in the vault threw and aborted the whole scan. The fix makes toWikiPageSummary() catch a frontmatter parse failure for the page it's currently summarizing, fall back to empty frontmatter for that one page, and record the failure on the summary instead of letting it propagate. wiki_lint now turns that into a normal invalid-frontmatter issue on the offending page instead of crashing. Call sites that parse one specific page they're about to edit (e.g. applyCreateSynthesisMutation) are untouched and still throw, since silently treating an edit target's broken frontmatter as empty risks losing that page's existing metadata on write.

User Impact

wiki_apply and wiki_lint no longer fail because of an unrelated page somewhere else in the vault. A page with broken frontmatter now shows up as a clear, actionable invalid-frontmatter lint finding pointing at that specific file, instead of taking down every wiki operation until someone manually finds and fixes it.

Evidence

New regression tests reproducing the reported scenario (a sourceIds entry with an inline colon inside bold text):

$ node scripts/run-vitest.mjs extensions/memory-wiki/src/markdown.test.ts extensions/memory-wiki/src/lint.test.ts extensions/memory-wiki/src/compile.test.ts extensions/memory-wiki/src/apply.test.ts extensions/memory-wiki/src/query.test.ts extensions/memory-wiki/src/status.test.ts
 Test Files  6 passed (6)
      Tests  78 passed (78)
[test] passed 1 Vitest shard in 7.20s
$ pnpm tsgo:extensions
$ pnpm tsgo:extensions:test

both clean.

$ pnpm format:check -- extensions/memory-wiki/src/markdown.ts extensions/memory-wiki/src/lint.ts extensions/memory-wiki/src/markdown.test.ts extensions/memory-wiki/src/lint.test.ts
All matched files use the correct format.
$ git diff --check
# no output

…tter

wiki_apply and wiki_lint recompile the whole vault after their own write,
which parses every page's frontmatter. One page with unparsable YAML
(e.g. a sourceIds list item containing an inline colon) threw out of the
scan and failed the entire operation, even though the requested write or
lint had already succeeded.

toWikiPageSummary now degrades a page with bad frontmatter to an empty
frontmatter instead of throwing, recording the parse failure on the
summary. Lint surfaces it as an invalid-frontmatter issue on that page
instead of crashing the whole vault scan. Callers that parse one
specific page they're about to mutate still throw as before.

Closes openclaw#96125
@clawsweeper

clawsweeper Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.

Close this PR as superseded: it targets a valid memory-wiki bug, but #97177 now carries the same summary/lint-scoped fix with stronger control coverage, sufficient real proof, and a clean mergeable state.

Canonical path: Land #97177 as the single proof-backed fix for the canonical memory-wiki frontmatter bug, then close #96125 after it merges.

So I’m closing this here and keeping the remaining discussion on #97177 and #96125.

Review details

Best possible solution:

Land #97177 as the single proof-backed fix for the canonical memory-wiki frontmatter bug, then close #96125 after it merges.

Do we have a high-confidence way to reproduce the issue?

Yes. Source inspection shows malformed frontmatter reaches YAML.parse, readPageSummaries stops and rethrows, and both wiki_apply and wiki_lint reach compileMemoryWikiVault.

Is this the best way to solve the issue?

No for this branch as the landing path. The fix shape is reasonable, but #97177 is the better canonical route because it implements the same boundary with extra control/body-preservation coverage and sufficient proof.

Security review:

Security review cleared: No concrete security or supply-chain concern was found; the diff only changes memory-wiki parsing, lint reporting, and colocated tests.

AGENTS.md: found and applied where relevant.

What I checked:

Likely related people:

  • vincentkoc: Git history shows Vincent Koc restored the memory-wiki stack, added lint tooling, and recently merged adjacent memory-wiki markdown work. (role: feature owner and recent merger; confidence: high; commits: 5716d83336fd, 9ce4abfe558e, c896718acb; files: extensions/memory-wiki/src/markdown.ts, extensions/memory-wiki/src/compile.ts, extensions/memory-wiki/src/lint.ts)
  • steipete: Recent PR metadata and history show bounded compile-read and shared coercion refactor work touching the memory-wiki compile and markdown-adjacent surfaces. (role: recent area contributor; confidence: medium; commits: acbdb8c373d8, 77d9ac30bb8d; files: extensions/memory-wiki/src/compile.ts, extensions/memory-wiki/src/markdown.ts, extensions/memory-wiki/src/lint.ts)
  • yetval: PR metadata shows recent memory-wiki source re-ingest work that touched markdown parsing/preservation behavior near this surface. (role: recent adjacent contributor; confidence: medium; commits: 0ec12df24512; files: extensions/memory-wiki/src/markdown.ts, extensions/memory-wiki/src/ingest.ts)
  • liuhao1024: A recent merged memory-wiki PR by this author changed markdown.ts and adjacent lint coverage after this branch was opened. (role: recent adjacent contributor; confidence: medium; commits: 73dc1212b0c7, 1e1ae6f6f0fb; files: extensions/memory-wiki/src/markdown.ts, extensions/memory-wiki/src/lint.test.ts)

Codex review notes: model internal, reasoning high; reviewed against 3811001d2783.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. labels Jun 24, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jun 27, 2026
@clawsweeper

clawsweeper Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper applied the proposed close for this PR.

@clawsweeper clawsweeper Bot closed this Jun 30, 2026
@steipete

steipete commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

The canonical fix has now landed via #97177 in commit 1289abddcb966cfa1535c7b82a08f555d9848445.

This PR remains correctly closed as superseded. The landed version uses a closed scan result so invalid pages cannot contaminate indexes, digests, counts, or query results, and it keeps all Markdown write targets strict and byte-preserving.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: memory-wiki P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: wiki_apply & wiki_lint YAML 解析错误

2 participants