siyuan-note/siyuan · error
invalid encoded style entity in attribute view rich text…
Error message
invalid encoded style entity in attribute view rich text span
What it means
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.
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
Example fix
// before
<span data-type="text">abc'</span>{: style="color:#f00"x'"}abc'
// after
<span data-type="text">abc</span>{: style="color:#f00"x""} Defensive patterns
Strategy: validation
Validate before calling
if strings.Count(style, token) != 1 { return errors.New("protection token must appear exactly once in style") } Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- encoded style entity is not attached to an attribute view…
- inconsistent attribute view rich text style entity sentinel
- unsupported attribute view rich text node
- attribute view rich text normalization did not converge
- attribute view rich text style entity sentinel was not…
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/5517899de5956265.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/av/value.go:1962
ast.Walk(tree.Root, func(node *ast.Node, entering bool) ast.WalkStatus {
if !entering {
return ast.WalkContinue
}
style := node.IALAttr("style")
styleProtected := strings.Contains(style, sentinel)
textProtected := ast.NodeTextMark == node.Type && strings.Contains(node.TextMarkTextContent, sentinel)
inlineMathProtected := ast.NodeTextMark == node.Type &&
strings.Contains(node.TextMarkInlineMathContent, sentinel)
tokens := string(node.Tokens)
tokensProtected := strings.Contains(tokens, sentinel)
if styleProtected {
if !node.IsTextMarkType("text") {
err = fmt.Errorf("encoded style entity is not attached to an attribute view rich text span")
return ast.WalkStop
}
if textProtected || inlineMathProtected || tokensProtected ||
!markValueTextRichStyleProtections(style, sentinel, tokenIndexes, restored) {
err = fmt.Errorf("invalid encoded style entity in attribute view rich text span")
return ast.WalkStop
}
style = styleReplacer.Replace(style)
node.SetIALAttr("style", style)
if nil != node.Next && ast.NodeKramdownSpanIAL == node.Next.Type {
node.Next.Tokens = parse.IAL2Tokens(node.KramdownIAL)
}
return ast.WalkContinue
}
if textProtected || inlineMathProtected {
if !node.IsTextMarkType("code") && !node.IsTextMarkType("inline-math") {
err = fmt.Errorf("invalid encoded style entity in attribute view rich text mark [%s]", node.TextMarkType)
return ast.WalkStop
}
if tokensProtected || textProtected &&
!markValueTextRichStyleProtections(node.TextMarkTextContent, sentinel, tokenIndexes, restored) ||
inlineMathProtected &&
!markValueTextRichStyleProtections(node.TextMarkInlineMathContent, sentinel, tokenIndexes, restored) {View on GitHub (pinned to 9f775e8a12)