{"record":{"id":"5517899de5956265","repo":"siyuan-note/siyuan","slug":"invalid-encoded-style-entity-in-attribute-view-ric","errorCode":null,"errorMessage":"invalid encoded style entity in attribute view rich text span","messagePattern":"invalid encoded style entity in attribute view rich text span","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/av/value.go","lineNumber":1962,"sourceCode":"\tast.Walk(tree.Root, func(node *ast.Node, entering bool) ast.WalkStatus {\n\t\tif !entering {\n\t\t\treturn ast.WalkContinue\n\t\t}\n\t\tstyle := node.IALAttr(\"style\")\n\t\tstyleProtected := strings.Contains(style, sentinel)\n\t\ttextProtected := ast.NodeTextMark == node.Type && strings.Contains(node.TextMarkTextContent, sentinel)\n\t\tinlineMathProtected := ast.NodeTextMark == node.Type &&\n\t\t\tstrings.Contains(node.TextMarkInlineMathContent, sentinel)\n\t\ttokens := string(node.Tokens)\n\t\ttokensProtected := strings.Contains(tokens, sentinel)\n\t\tif styleProtected {\n\t\t\tif !node.IsTextMarkType(\"text\") {\n\t\t\t\terr = fmt.Errorf(\"encoded style entity is not attached to an attribute view rich text span\")\n\t\t\t\treturn ast.WalkStop\n\t\t\t}\n\t\t\tif textProtected || inlineMathProtected || tokensProtected ||\n\t\t\t\t!markValueTextRichStyleProtections(style, sentinel, tokenIndexes, restored) {\n\t\t\t\terr = fmt.Errorf(\"invalid encoded style entity in attribute view rich text span\")\n\t\t\t\treturn ast.WalkStop\n\t\t\t}\n\t\t\tstyle = styleReplacer.Replace(style)\n\t\t\tnode.SetIALAttr(\"style\", style)\n\t\t\tif nil != node.Next && ast.NodeKramdownSpanIAL == node.Next.Type {\n\t\t\t\tnode.Next.Tokens = parse.IAL2Tokens(node.KramdownIAL)\n\t\t\t}\n\t\t\treturn ast.WalkContinue\n\t\t}\n\t\tif textProtected || inlineMathProtected {\n\t\t\tif !node.IsTextMarkType(\"code\") && !node.IsTextMarkType(\"inline-math\") {\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\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) {","sourceCodeStart":1944,"sourceCodeEnd":1980,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/av/value.go#L1944-L1980","documentation":"A text-mark span's style contains an encoded style entity sentinel, but the entity is invalid: either the sentinel also appears in the node's text content, inline math content, or raw tokens (forbidden places), or markValueTextRichStyleProtections could not match/consume the protection (duplicate, unknown, or partially consumed token). The kernel refuses to restore rather than silently corrupt the style.","triggerScenarios":"The restore walk (kernel/av/value.go:1962) hits styleProtected && textMarkType \"text\" but (textProtected || inlineMathProtected || tokensProtected) is true, or the token is not present/marked exactly once in tokenIndexes via markValueTextRichStyleProtections.","commonSituations":"Sentinel tokens accidentally pasted into visible cell text; duplicated IAL styles sharing one protection token; a protection token appearing twice in the same style; hand-edited kramdown copying sentinel strings around.","solutions":["Remove any sentinel-token strings from the span's visible text, inline math content, and raw tokens — sentinels may exist only inside the style IAL","Ensure each protection token appears exactly once across all styles; deduplicate repeated style IALs","Regenerate the content by editing the value in the SiYuan editor so protect/restore runs cleanly end-to-end","If hand-migrating data, decode the encoded entities (restore the original characters) and drop the sentinel markers before re-storing"],"exampleFix":"// before\n<span data-type=\"text\">abc&apos;</span>{: style=\"color:#f00&quot;x&apos;\"}abc&apos;\n// after\n<span data-type=\"text\">abc</span>{: style=\"color:#f00&quot;x&quot;\"}","handlingStrategy":"validation","validationCode":"if strings.Count(style, token) != 1 { return errors.New(\"protection token must appear exactly once in style\") }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ensure sentinel tokens never appear in visible text or inline math","Deduplicate style IALs so each token is consumed once","Avoid duplicating spans that contain sentinel-bearing styles","Run full protect/parse/restore round-trip tests on generated content"],"tags":["attribute-view","rich-text","entity-protection","ast-validation"],"backgroundTag":"internal-invariant-violation","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"}