{"record":{"id":"aeb4a0c256427138","repo":"siyuan-note/siyuan","slug":"invalid-encoded-style-entity-in-attribute-view-ric-aeb4a0","errorCode":null,"errorMessage":"invalid encoded style entity in attribute view rich text node [%s]","messagePattern":"invalid encoded style entity in attribute view rich text node \\[(.+?)\\]","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/av/value.go","lineNumber":1986,"sourceCode":"\t\t\t}\n\t\t\tif tokensProtected || textProtected &&\n\t\t\t\t!markValueTextRichStyleProtections(node.TextMarkTextContent, sentinel, tokenIndexes, restored) ||\n\t\t\t\tinlineMathProtected &&\n\t\t\t\t\t!markValueTextRichStyleProtections(node.TextMarkInlineMathContent, sentinel, tokenIndexes, restored) {\n\t\t\t\terr = fmt.Errorf(\"invalid encoded style entity in attribute view rich text mark [%s]\", node.TextMarkType)\n\t\t\t\treturn ast.WalkStop\n\t\t\t}\n\t\t\tnode.TextMarkTextContent = textMarkCodeReplacer.Replace(node.TextMarkTextContent)\n\t\t\tnode.TextMarkInlineMathContent = textMarkInlineMathReplacer.Replace(node.TextMarkInlineMathContent)\n\t\t\treturn ast.WalkContinue\n\t\t}\n\t\tif !tokensProtected {\n\t\t\treturn ast.WalkContinue\n\t\t}\n\t\tswitch node.Type {\n\t\tcase ast.NodeCodeBlockCode, ast.NodeMathBlockContent, ast.NodeCodeSpanContent, ast.NodeInlineMathContent:\n\t\t\tif !markValueTextRichStyleProtections(tokens, sentinel, tokenIndexes, restored) {\n\t\t\t\terr = fmt.Errorf(\"invalid encoded style entity in attribute view rich text node [%s]\", node.Type.String())\n\t\t\t\treturn ast.WalkStop\n\t\t\t}\n\t\t\tnode.Tokens = []byte(literalReplacer.Replace(tokens))\n\t\tdefault:\n\t\t\terr = fmt.Errorf(\"invalid encoded style entity in attribute view rich text node [%s]\", node.Type.String())\n\t\t\treturn ast.WalkStop\n\t\t}\n\t\treturn ast.WalkContinue\n\t})\n\tif nil != err {\n\t\treturn\n\t}\n\tfor _, found := range restored {\n\t\tif !found {\n\t\t\treturn fmt.Errorf(\"attribute view rich text style entity was not restored\")\n\t\t}\n\t}\n\tast.Walk(tree.Root, func(node *ast.Node, entering bool) ast.WalkStatus {","sourceCodeStart":1968,"sourceCodeEnd":2004,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/av/value.go#L1968-L2004","documentation":"A non-text-mark node's raw Tokens contain the sentinel, and the node type is one of the literal-preserving types (code block code, math block content, code span content, inline math content), but the sentinel occurrences could not be matched to complete known protection tokens. These literal node types are the only places raw token protection is allowed, and each occurrence must map to a valid token index.","triggerScenarios":"Normalizing rich text where a code block, math block, code span, or inline math node's Tokens hold a malformed sentinel token (unknown index or missing \\ue002 terminator) generated outside the current protection pass.","commonSituations":"External editing of .sy-derived Kramdown code fences; truncated copy/paste of protected content; a mismatch between the protection slice and the tree after partial re-parsing.","solutions":["Repair the sentinel token inside the literal node so it is a complete sentinel+index+\\ue002 token from the current protection set","Regenerate the rich text content through the client to rebuild the protection tokens","If content was merged programmatically, re-run protection over the merged tree instead of reusing old tokens"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const tokenRe = /\\ue000siyuan[^\\ue002]*\\ue002/g\nfor (const node of literalNodes(tree)) {\n  if ((node.tokens.match(/\\ue000/g) || []).length !== (node.tokens.match(tokenRe) || []).length) {\n    throw new Error(\"malformed sentinel token in literal node\")\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  await api.normalizeAvValueText(payload)\n} catch (e) {\n  if (String(e).includes(\"invalid encoded style entity in attribute view rich text node\")) {\n    payload = reEncodeRichText(payload)\n  }\n}","preventionTips":["Re-run protection over merged trees instead of reusing stale tokens","Avoid external tools that rewrite code fence content byte-for-byte","Regenerate rich text values after bulk content migrations"],"tags":["attribute-view","rich-text","literal-nodes","validation"],"backgroundTag":"invalid-argument-format","analyzedSha":"8641553a1f07374001902d3ce773285db1292b2d","analyzedAt":"2026-09-11T16:08:28.414Z","contentChangedAt":"2026-09-11T16:08:28.414Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}