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

  1. Set the Spec field to the current ValueTextRichSpec constant exported from kernel/av/value.go instead of hard-coding a number
  2. Unmarshal the JSON with the real ValueTextRich struct so Spec is populated correctly, rather than building it by hand
  3. 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
  4. 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

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


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)