siyuan-note/siyuan · error
invalid encoded style entity in attribute view rich text mar
Error message
invalid encoded style entity in attribute view rich text mark [%s]
What it means
A node carries the protection sentinel in its text content or inline math content, but its text mark type is neither "code" nor "inline-math". Sentinel-protected entities in TextMarkTextContent/TextMarkInlineMathContent are only restorable inside code and inline-math marks; on any other mark type the replacement would corrupt rendering, so the walker rejects the content.
Source
Thrown at kernel/av/value.go:1966
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) {
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:View on GitHub (pinned to 8641553a1f)
Solutions
- Change the offending mark's data-type to "code" or "inline-math", or strip the protection token from its content
- Re-encode the value through the official client so entities are protected in the correct mark types
- Check plugin/export tooling for code that moves TextMarkTextContent between mark types without re-running protection
Example fix
// before <span data-type="strong">see siyuan...0</span> // after <span data-type="code">see &lt;</span>
Defensive patterns
Strategy: validation
Validate before calling
const allowed = new Set(["code", "inline-math"])
for (const mark of textMarks(tree)) {
if ((mark.textContent + mark.inlineMathContent).includes("\ue000") && !allowed.has(mark.dataType)) {
throw new Error(`sentinel in disallowed mark type: ${mark.dataType}`)
}
} Type guard
const isCodeOrMathMark = (mark) => mark.dataType === "code" || mark.dataType === "inline-math"
Try / catch
try {
await api.normalizeAvValueText(payload)
} catch (e) {
if (String(e).includes("invalid encoded style entity in attribute view rich text mark")) {
payload = moveSentinelContentToCodeMarks(payload)
}
} Prevention
- Keep protected entities only in code/inline-math marks
- Audit plugins that rewrite mark data-type attributes
- Strip private-use sentinel characters from external content before import
When it happens
Trigger: Normalizing rich text where a mark such as "strong", "em", "a", or "tag" has TextMarkTextContent or TextMarkInlineMathContent containing a protection token produced by protectValueTextRichStyleEntities.
Common situations: Plugin or API clients that copied protection tokens into ordinary styled text; migrating content written by tooling that misclassified mark types; round-tripping Kramdown through an external editor that changed data-type attributes.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 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 nod
- wrong layout type
AI-assisted analysis of siyuan-note/siyuan@8641553a1f (2026-09-11).
Data as JSON: /api/errors/8c32aaa3d739ed33.
Report an issue: GitHub.