siyuan-note/siyuan · error
inconsistent attribute view rich text style entity sentinel
Error message
inconsistent attribute view rich text style entity sentinel
What it means
During restore of protected style entities, each recorded protection must carry the same sentinel token that was generated for this run; one protection record's sentinel differs from the loop's sentinel, so restoration cannot proceed safely. This is an internal consistency check on the protect/restore machinery that hides HTML-escaped entities in styles during parsing.
Solutions
- Always obtain protections and their sentinel from the same protectValueTextRichStyleEntities call and pass them together to restore in the same call
- Do not cache or merge protection slices across separate parse invocations
- If implementing custom processing, generate one sentinel per content string and reuse it for all protections of that string
- This is internal-invariant breakage: if seen in stock SiYuan without custom code, capture the content and file an issue
Defensive patterns
Strategy: type-guard
Validate before calling
for _, p := range protections { if p.sentinel != expectedSentinel { return errors.New("stale protection slice") } } Prevention
- Pair protect and restore calls one-to-one, never across invocations
- Don't cache protection slices; regenerate per content string
- Scope sentinel generation per call site
- Cover protect/restore pairing with round-trip tests
When it happens
Trigger: restoreValueTextRichTreeStyleEntities (kernel/av/value.go:1929 region) invoked with protections produced by a different protect call, or protections mixed from multiple runs so their sentinel fields disagree.
Common situations: Custom Go code calling the protected internal functions directly and caching protections across calls; concurrent/mis-sequenced protect-restore pairing; a refactor that passed stale protection slices.
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…
- invalid encoded style entity in attribute view rich text…
- attribute view has no primary key field
- 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/fc2e994e84ff2808.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/av/value.go:1929
}
return builder.String(), protections
}
func restoreValueTextRichTreeStyleEntities(tree *parse.Tree,
protections []valueTextRichStyleEntityProtection) (err error) {
if 1 > len(protections) {
return
}
sentinel := protections[0].sentinel
stylePairs := make([]string, 0, len(protections)*2)
literalPairs := make([]string, 0, len(protections)*2)
textMarkCodePairs := make([]string, 0, len(protections)*2)
textMarkInlineMathPairs := make([]string, 0, len(protections)*2)
tokenIndexes := make(map[string]int, len(protections))
restored := make([]bool, len(protections))
for i, protection := range protections {
if sentinel != protection.sentinel {
return fmt.Errorf("inconsistent attribute view rich text style entity sentinel")
}
tokenIndexes[protection.token] = i
stylePairs = append(stylePairs, protection.token, protection.decoded)
literalPairs = append(literalPairs, protection.token, protection.encoded)
encoded := strings.ReplaceAll(protection.encoded, "&", "&")
textMarkCodePairs = append(textMarkCodePairs, protection.token, encoded)
textMarkInlineMathPairs = append(textMarkInlineMathPairs, protection.token,
strings.ReplaceAll(encoded, "&", "&"))
}
styleReplacer := strings.NewReplacer(stylePairs...)
literalReplacer := strings.NewReplacer(literalPairs...)
textMarkCodeReplacer := strings.NewReplacer(textMarkCodePairs...)
textMarkInlineMathReplacer := strings.NewReplacer(textMarkInlineMathPairs...)
ast.Walk(tree.Root, func(node *ast.Node, entering bool) ast.WalkStatus {
if !entering {
return ast.WalkContinue
}View on GitHub (pinned to 9f775e8a12)