siyuan-note/siyuan · error

unsupported attribute view rich text format

Error message

unsupported attribute view rich text format [%s]

What it means

This error means the Format field of a ValueTextRich is not the supported kramdown format constant ValueTextRichFormatKramdown. The rich text parser only accepts kramdown-encoded content; any other declared format string is rejected before parsing to prevent misinterpreting content stored in an unsupported serialization.

Solutions

  1. Set Format to av.ValueTextRichFormatKramdown (the string constant defined in kernel/av/value.go)
  2. If your content is plain markdown, convert/escape it into kramdown-compatible rich text (text marks with IAL) before storing
  3. Check the JSON source for a renamed field; ensure the format value round-trips through the ValueTextRich struct
  4. For data from another tool/version, re-export the attribute view content through SiYuan's own editor/API so it is re-serialized as kramdown

Example fix

// before
rich := &av.ValueTextRich{Spec: av.ValueTextRichSpec, Format: "markdown", Content: content}
// after
rich := &av.ValueTextRich{Spec: av.ValueTextRichSpec, Format: av.ValueTextRichFormatKramdown, Content: content}
Defensive patterns

Strategy: validation

Validate before calling

if rich.Format != av.ValueTextRichFormatKramdown { return fmt.Errorf("format %q unsupported; expected %q", rich.Format, av.ValueTextRichFormatKramdown) }

Try / catch

if _, err := av.ParseValueTextRich(rich); err != nil && strings.Contains(err.Error(), "unsupported attribute view rich text format") { rich.Format = av.ValueTextRichFormatKramdown; /* retry or reserialize */ }

Prevention

When it happens

Trigger: Calling ParseValueTextRich / ParseTableCellRich / normalizeValueTextRichTreeSourceWithImages with ValueTextRich.Format set to anything other than av.ValueTextRichFormatKramdown (e.g. "markdown", "html", or empty string from incomplete JSON).

Common situations: Hand-built API payloads using "markdown" instead of "kramdown"; older or third-party writers using a different format label; truncated JSON leaving Format empty.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19). Data as JSON: /api/errors/8989ed7320683ae5. Report an issue: GitHub.

Appendix: source

Thrown at kernel/av/value.go:569

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
	}
	if 0 < len(protectedStyleEntities) {
		if err = restoreValueTextRichTreeStyleEntities(tree, protectedStyleEntities); nil != err {
			return
		}

View on GitHub (pinned to 9f775e8a12)