siyuan-note/siyuan · error

ErrRichTextSpecMismatch

ErrRichTextSpecMismatch

Error message

attribute view rich text requires storage spec 9

What it means

ErrRichTextSpecMismatch is raised by CheckSpec when an attribute view contains rich-text values (ValueTextRichFormatKramdown) but its storage Spec is below the required RichTextSpec (9). Rich text requires the newer storage layout, so older-spec files with rich values are rejected instead of silently degraded.

Solutions

  1. Upgrade the attribute view's Spec to 9 (RichTextSpec) when it contains rich-text values
  2. Run the official spec-upgrade path rather than editing values manually
  3. Validate with CheckSpec after any migration; revert the value formats if spec must stay < 9

Example fix

// before
av := &AttributeView{Spec: 8, ...} // values rich
// after
if av.Spec < RichTextSpec && av.HasRichText() {
    av.Spec = RichTextSpec // upgrade storage spec
}
if err := CheckSpec(av); err != nil { return err }
Defensive patterns

Strategy: validation

Validate before calling

if av.Spec < av.RichTextSpec && av.HasRichText() {
    return errors.New("upgrade spec to 9 or strip rich-text values")
}

Try / catch

if err := CheckSpec(av); err != nil {
    if errors.Is(err, av.ErrRichTextSpecMismatch) {
        av.Spec = av.RichTextSpec // run official upgrade path
    }
}

Prevention

When it happens

Trigger: Loading/validating an attribute view where Spec < RichTextSpec and HasRichText() is true — e.g. hand-edited or partially migrated JSON where values were upgraded but the spec field wasn't; TestUpgradeSpec9OnlyForRichText exercises the mismatch branch.

Common situations: A custom migration script bumped value formats but forgot to set spec to 9; merging attribute views from different versions; downgrade followed by edits reintroducing rich values into an old-spec file.

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


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

Appendix: source

Thrown at kernel/av/av.go:1392

	}
	return
}

func GetAttributeViewI18n(key string) string {
	return util.AttrViewLangs[util.Lang][key].(string)
}

var (
	ErrAttributeViewNotFound  = errors.New("attribute view not found")
	ErrInvalidAttributeViewID = errors.New("invalid attribute view id")
	ErrInvalidBoxID           = errors.New("invalid box id")
	ErrViewNotFound           = errors.New("view not found")
	ErrKeyNotFound            = errors.New("key not found")
	ErrItemNotFound           = errors.New("item not found")
	ErrWrongLayoutType        = errors.New("wrong layout type")
	ErrInvalidColumnAlign     = errors.New("invalid column align")
	ErrSpecTooNew             = errors.New("attribute view spec is too new")
	ErrRichTextSpecMismatch   = errors.New("attribute view rich text requires storage spec 9")
	ErrFilterTooDeep          = errors.New("filter nesting depth exceeds the maximum allowed")
)

const (
	NodeAttrNameAvs        = "custom-avs"                  // 用于标记块所属的属性视图,逗号分隔 av id
	NodeAttrView           = "custom-sy-av-view"           // 用于标记块所属的属性视图视图 view id Database block support specified view https://github.com/siyuan-note/siyuan/issues/10443
	NodeAttrVisibleViewIDs = "custom-sy-av-visible-views"  // 用于标记数据库块显示的视图 ID,逗号分隔
	NodeAttrContextFilter  = "custom-sy-av-context-filter" // 用于保存数据库块独有的上下文筛选配置
	NodeAttrViewStaticText = "custom-sy-av-s-text"         // 用于标记块所属的属性视图静态文本 Database-bound block primary key supports setting static anchor text https://github.com/siyuan-note/siyuan/issues/10049

	NodeAttrViewNames = "av-names" // 用于临时标记块所属的属性视图名称,空格分隔
)

View on GitHub (pinned to 9f775e8a12)