{"record":{"id":"3bcbc756ef44b9df","repo":"siyuan-note/siyuan","slug":"errrichtextspecmismatch","errorCode":"ErrRichTextSpecMismatch","errorMessage":"attribute view rich text requires storage spec 9","messagePattern":"attribute view rich text requires storage spec 9","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/av/av.go","lineNumber":1348,"sourceCode":"\t}\n\treturn\n}\n\nfunc GetAttributeViewI18n(key string) string {\n\treturn util.AttrViewLangs[util.Lang][key].(string)\n}\n\nvar (\n\tErrAttributeViewNotFound  = errors.New(\"attribute view not found\")\n\tErrInvalidAttributeViewID = errors.New(\"invalid attribute view id\")\n\tErrInvalidBoxID           = errors.New(\"invalid box id\")\n\tErrViewNotFound           = errors.New(\"view not found\")\n\tErrKeyNotFound            = errors.New(\"key not found\")\n\tErrItemNotFound           = errors.New(\"item not found\")\n\tErrWrongLayoutType        = errors.New(\"wrong layout type\")\n\tErrInvalidColumnAlign     = errors.New(\"invalid column align\")\n\tErrSpecTooNew             = errors.New(\"attribute view spec is too new\")\n\tErrRichTextSpecMismatch   = errors.New(\"attribute view rich text requires storage spec 9\")\n\tErrFilterTooDeep          = errors.New(\"filter nesting depth exceeds the maximum allowed\")\n)\n\nconst (\n\tNodeAttrNameAvs        = \"custom-avs\"                  // 用于标记块所属的属性视图，逗号分隔 av id\n\tNodeAttrView           = \"custom-sy-av-view\"           // 用于标记块所属的属性视图视图 view id Database block support specified view https://github.com/siyuan-note/siyuan/issues/10443\n\tNodeAttrVisibleViewIDs = \"custom-sy-av-visible-views\"  // 用于标记数据库块显示的视图 ID，逗号分隔\n\tNodeAttrContextFilter  = \"custom-sy-av-context-filter\" // 用于保存数据库块独有的上下文筛选配置\n\tNodeAttrViewStaticText = \"custom-sy-av-s-text\"         // 用于标记块所属的属性视图静态文本 Database-bound block primary key supports setting static anchor text https://github.com/siyuan-note/siyuan/issues/10049\n\n\tNodeAttrViewNames = \"av-names\" // 用于临时标记块所属的属性视图名称，空格分隔\n)\n","sourceCodeStart":1330,"sourceCodeEnd":1361,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/av/av.go#L1330-L1361","documentation":"ErrRichTextSpecMismatch means an attribute view contains rich-text (kramdown) cell values but its storage Spec is below RichTextSpec (9), so the storage format cannot represent rich text. CheckSpec rejects the view to prevent silently degrading rich-text content to plain text.","triggerScenarios":"Calling av.CheckSpec on an AttributeView with Spec < 9 and at least one text value with Format == ValueTextRichFormatKramdown (av_fix.go:60); deserializing/hand-editing a .av file whose spec was lowered; tests like TestUpgradeSpec9OnlyForRichText exercise this branch.","commonSituations":"A .av file was produced by a newer version (which upgrades Spec to 9 for rich text) but then partially reverted or hand-edited to an older spec; a sync conflict merged a rich-text value into an old-spec file; manual migration tooling lowered the spec.","solutions":["Set the attribute view's Spec to RichTextSpec (9) before persisting rich-text values — normally done automatically by upgradeSpec9 during load/save.","Remove or convert the rich-text values (Format kramdown -> plain) if the view must stay on the old spec.","Re-generate the .av file from a consistent source (its document tree) instead of merging specs by hand.","If this appears while writing code, ensure custom serialization paths call av.CheckSpec before save and upgrade the spec via the provided fix helpers."],"exampleFix":"// before\nav.Spec = 8\nav.Values[\"k1\"].Text = &av.ValueText{ValueTextRichSpec: 9, Format: av.ValueTextRichFormatKramdown}\n\n// after\nav.Spec = av.RichTextSpec // 9, matches the rich text content\n// or: strip rich text before saving on an old spec","handlingStrategy":"validation","validationCode":"func hasRichTextAtOldSpec(v *av.AttributeView) bool {\n\treturn v.Spec < av.RichTextSpec && v.HasRichText()\n}","typeGuard":null,"tryCatchPattern":"if err := av.CheckSpec(v); errors.Is(err, av.ErrRichTextSpecMismatch) {\n\t// upgrade spec or strip rich text before saving\n}","preventionTips":["Always run CheckSpec before saving .av JSON","Never hand-edit the spec field; let upgradeSpec9 handle upgrades","Avoid merging .av files from different versions manually"],"tags":["attribute-view","rich-text","spec-version","schema-validation","siyuan-kernel"],"backgroundTag":"schema-validation-failed","analyzedSha":"8641553a1f07374001902d3ce773285db1292b2d","analyzedAt":"2026-09-11T16:08:28.414Z","contentChangedAt":"2026-09-11T16:08:28.414Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}