siyuan-note/siyuan · error
invalid encoded style entity in attribute view rich text nod
Error message
invalid encoded style entity in attribute view rich text node [%s]
What it means
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.
Source
Thrown at kernel/av/value.go:1986
}
if tokensProtected || textProtected &&
!markValueTextRichStyleProtections(node.TextMarkTextContent, sentinel, tokenIndexes, restored) ||
inlineMathProtected &&
!markValueTextRichStyleProtections(node.TextMarkInlineMathContent, sentinel, tokenIndexes, restored) {
err = fmt.Errorf("invalid encoded style entity in attribute view rich text mark [%s]", node.TextMarkType)
return ast.WalkStop
}
node.TextMarkTextContent = textMarkCodeReplacer.Replace(node.TextMarkTextContent)
node.TextMarkInlineMathContent = textMarkInlineMathReplacer.Replace(node.TextMarkInlineMathContent)
return ast.WalkContinue
}
if !tokensProtected {
return ast.WalkContinue
}
switch node.Type {
case ast.NodeCodeBlockCode, ast.NodeMathBlockContent, ast.NodeCodeSpanContent, ast.NodeInlineMathContent:
if !markValueTextRichStyleProtections(tokens, sentinel, tokenIndexes, restored) {
err = fmt.Errorf("invalid encoded style entity in attribute view rich text node [%s]", node.Type.String())
return ast.WalkStop
}
node.Tokens = []byte(literalReplacer.Replace(tokens))
default:
err = fmt.Errorf("invalid encoded style entity in attribute view rich text node [%s]", node.Type.String())
return ast.WalkStop
}
return ast.WalkContinue
})
if nil != err {
return
}
for _, found := range restored {
if !found {
return fmt.Errorf("attribute view rich text style entity was not restored")
}
}
ast.Walk(tree.Root, func(node *ast.Node, entering bool) ast.WalkStatus {View on GitHub (pinned to 8641553a1f)
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
Defensive patterns
Strategy: validation
Validate before calling
const tokenRe = /\ue000siyuan[^\ue002]*\ue002/g
for (const node of literalNodes(tree)) {
if ((node.tokens.match(/\ue000/g) || []).length !== (node.tokens.match(tokenRe) || []).length) {
throw new Error("malformed sentinel token in literal node")
}
} Try / catch
try {
await api.normalizeAvValueText(payload)
} catch (e) {
if (String(e).includes("invalid encoded style entity in attribute view rich text node")) {
payload = reEncodeRichText(payload)
}
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- attribute view rich text tree is missing
- encoded style entity is not attached to an attribute view ri
- invalid encoded style entity in attribute view rich text spa
- invalid encoded style entity in attribute view rich text mar
- wrong layout type
AI-assisted analysis of siyuan-note/siyuan@8641553a1f (2026-09-11).
Data as JSON: /api/errors/aeb4a0c256427138.
Report an issue: GitHub.