siyuan-note/siyuan · error
unsupported attribute view rich text spec
Error message
unsupported attribute view rich text spec [%d]
What it means
This error means the Spec field of a ValueTextRich (attribute view rich text payload) does not match the currently supported spec constant ValueTextRichSpec. The kernel rejects rich text data written by an unknown/other spec version so that content from a different format generation is never misinterpreted. It is a forward/backward compatibility guard at the parser entry point used by table cell and text value parsing.
Solutions
- Set the Spec field to the current ValueTextRichSpec constant exported from kernel/av/value.go instead of hard-coding a number
- Unmarshal the JSON with the real ValueTextRich struct so Spec is populated correctly, rather than building it by hand
- If the data came from another SiYuan version, upgrade/downgrade to a version whose ValueTextRichSpec matches, and let migration run before reading the attribute view
- If zero, check whether the value object was constructed but never populated; initialize Rich from a parsed source instead
Example fix
// before
rich := &av.ValueTextRich{Format: av.ValueTextRichFormatKramdown, Content: content}
// after
rich := &av.ValueTextRich{Spec: av.ValueTextRichSpec, Format: av.ValueTextRichFormatKramdown, Content: content} Defensive patterns
Strategy: validation
Validate before calling
if rich.Spec != av.ValueTextRichSpec { return fmt.Errorf("spec %d unsupported; expected %d", rich.Spec, av.ValueTextRichSpec) } Try / catch
tree, err := av.ParseValueTextRich(rich); if err != nil && strings.Contains(err.Error(), "unsupported attribute view rich text spec") { /* reserialize via editor or remap spec */ } Prevention
- Always initialize ValueTextRich via its exported constants, never raw integers
- When copying rich text records between stores, copy the whole struct, not selected fields
- Round-trip test payloads through marshal/unmarshal of the real struct before sending to the kernel
- Track SiYuan version upgrades for spec constant changes
When it happens
Trigger: Calling ParseTableCellRich, ParseValueTextRich, or any path reaching parseValueTextRichWithImages with a *ValueTextRich whose Spec field is not the current ValueTextRichSpec constant (e.g. Spec: 2 when the kernel expects 1, or Spec left as zero value 0 when unmarshalling partial JSON).
Common situations: Restoring/copying .sy or DB data written by a newer (or older) SiYuan version; hand-crafting API payloads and omitting the spec field; plugin code constructing ValueTextRich manually; corrupted attribute-view records.
Related errors
- attribute view rich text normalization did not converge
- attribute view rich text style entity sentinel was not…
- attribute view rich text style entity was not restored
- attribute view rich text tree is missing
- encoded style entity is not attached to an attribute view…
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/14cbb4b62489d92c.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/av/value.go:565
return nil != value && nil != value.Rich
}
// ParseValueTextRich 校验并解析文本字段的富文本源。
func ParseValueTextRich(rich *ValueTextRich) (tree *parse.Tree, err error) {
_, tree, err = parseValueTextRich(rich)
return
}
func parseValueTextRich(rich *ValueTextRich) (blockDOM string, tree *parse.Tree, err error) {
return parseValueTextRichWithImages(rich, false)
}
func parseValueTextRichWithImages(rich *ValueTextRich, images bool) (blockDOM string, tree *parse.Tree, err error) {
if nil == rich {
return
}
if ValueTextRichSpec != rich.Spec {
err = fmt.Errorf("unsupported attribute view rich text spec [%d]", rich.Spec)
return
}
if ValueTextRichFormatKramdown != rich.Format {
err = fmt.Errorf("unsupported attribute view rich text format [%s]", rich.Format)
return
}
luteEngine := newValueTextRichLute()
content, protectedStyleEntities, protectErr := protectValueTextRichKramdownStyleEntities(rich.Content)
if nil != protectErr {
err = protectErr
return
}
blockDOM, tree = luteEngine.Md2BlockDOMTree(content, true)
if nil == tree || nil == tree.Root {
err = fmt.Errorf("parse attribute view rich text failed")
return
}View on GitHub (pinned to 9f775e8a12)