{"record":{"id":"e2dde3e2ec83e27e","repo":"siyuan-note/siyuan","slug":"parse-attribute-view-rich-text-failed","errorCode":null,"errorMessage":"parse attribute view rich text failed","messagePattern":"parse attribute view rich text failed","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/av/value.go","lineNumber":581,"sourceCode":"\t}\n\tif ValueTextRichSpec != rich.Spec {\n\t\terr = fmt.Errorf(\"unsupported attribute view rich text spec [%d]\", rich.Spec)\n\t\treturn\n\t}\n\tif ValueTextRichFormatKramdown != rich.Format {\n\t\terr = fmt.Errorf(\"unsupported attribute view rich text format [%s]\", rich.Format)\n\t\treturn\n\t}\n\n\tluteEngine := newValueTextRichLute()\n\tcontent, protectedStyleEntities, protectErr := protectValueTextRichKramdownStyleEntities(rich.Content)\n\tif nil != protectErr {\n\t\terr = protectErr\n\t\treturn\n\t}\n\tblockDOM, tree = luteEngine.Md2BlockDOMTree(content, true)\n\tif nil == tree || nil == tree.Root {\n\t\terr = fmt.Errorf(\"parse attribute view rich text failed\")\n\t\treturn\n\t}\n\tif 0 < len(protectedStyleEntities) {\n\t\tif err = restoreValueTextRichTreeStyleEntities(tree, protectedStyleEntities); nil != err {\n\t\t\treturn\n\t\t}\n\t\tblockDOM = luteEngine.Tree2BlockDOM(tree, luteEngine.RenderOptions, luteEngine.ParseOptions)\n\t}\n\terr = validateValueTextRichTreeWithImages(tree, images)\n\treturn\n}\n\nfunc validateValueTextRichTree(tree *parse.Tree) (err error) {\n\treturn validateValueTextRichTreeWithImages(tree, false)\n}\n\nfunc validateValueTextRichTreeWithImages(tree *parse.Tree, images bool) (err error) {\n\tif nil == tree || nil == tree.Root {","sourceCodeStart":563,"sourceCodeEnd":599,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/av/value.go#L563-L599","documentation":"The lute engine finished Md2BlockDOMTree on the kramdown content but produced a nil tree or a nil root, meaning the rich text content could not be parsed into a block DOM AST at all. Unlike per-node validation errors, this signals total parse failure — lute returned no usable tree for the given content string.","triggerScenarios":"Calling ParseValueTextRich / ParseTableCellRich / normalizeValueTextRichTreeSourceWithImages with content so malformed that lute.Md2BlockDOMTree returns nil or a tree without Root (nil/empty content edge cases, deeply corrupted markup after entity protection).","commonSituations":"Passing an empty or whitespace-only Content string; corrupted rich text from a crashed sync; programmatically spliced content where the kramdown IAL markers are unbalanced.","solutions":["Ensure Content is non-empty, valid kramdown before calling the parse APIs","Inspect the content string for unbalanced kramdown IAL ({: style=\"...\"}) or HTML/text-mark constructs and fix them","Re-open the attribute view value in the SiYuan editor and re-save so the kernel re-serializes the content from the DOM","If the data is corrupted by sync, restore the affected document from file history or sync snapshots"],"exampleFix":"// before\nrich := &av.ValueTextRich{Spec: av.ValueTextRichSpec, Format: av.ValueTextRichFormatKramdown, Content: \"\"}\n// after\nif strings.TrimSpace(content) == \"\" { content = \"placeholder\" }\nrich := &av.ValueTextRich{Spec: av.ValueTextRichSpec, Format: av.ValueTextRichFormatKramdown, Content: content}","handlingStrategy":"try-catch","validationCode":"if strings.TrimSpace(content) == \"\" { content = \"\" } // treat empty as no rich text: set Rich=nil instead","typeGuard":null,"tryCatchPattern":"_, err := av.ParseValueTextRich(rich); if err != nil && strings.Contains(err.Error(), \"parse attribute view rich text failed\") { fallbackPlain := value.Text; /* fall back to plain text rendering */ }","preventionTips":["Never persist hand-spliced kramdown; let the editor serialize content","Keep content non-empty or set Rich to nil for plain values","After failed writes/sync, verify attribute view content parses before reuse","Test with lute Md2BlockDOMTree directly when generating content programmatically"],"tags":["attribute-view","rich-text","parse-error","lute"],"backgroundTag":"xml-parse-error","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}