{"record":{"id":"cfaabaf385bf100b","repo":"siyuan-note/siyuan","slug":"invalid-table-cell-rich-text-document-spec-s","errorCode":null,"errorMessage":"invalid table cell rich text document spec [%s]","messagePattern":"invalid table cell rich text document spec \\[(.+?)\\]","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/treenode/table_cell_rich.go","lineNumber":37,"sourceCode":"func checkTableCellRichJSON(data []byte, spec string) error {\n\ttype rawNode struct {\n\t\tType          string\n\t\tTableCellRich json.RawMessage\n\t\tChildren      []json.RawMessage\n\t}\n\tvar check func(json.RawMessage, string) error\n\tcheck = func(raw json.RawMessage, context string) error {\n\t\tvar node rawNode\n\t\tif err := json.Unmarshal(raw, &node); nil != err {\n\t\t\treturn err\n\t\t}\n\t\tif len(node.TableCellRich) > 0 {\n\t\t\tif !utf8.Valid(node.TableCellRich) {\n\t\t\t\treturn fmt.Errorf(\"table cell rich text payload is not UTF-8\")\n\t\t\t}\n\t\t\tversion, _ := strconv.Atoi(spec)\n\t\t\tif version < 4 || node.Type != \"NodeTableCell\" || context != \"row\" {\n\t\t\t\treturn fmt.Errorf(\"invalid table cell rich text document spec [%s]\", spec)\n\t\t\t}\n\t\t\tvar fields map[string]json.RawMessage\n\t\t\tif err := json.Unmarshal(node.TableCellRich, &fields); nil != err || len(fields) != 3 {\n\t\t\t\treturn fmt.Errorf(\"invalid table cell rich text payload\")\n\t\t\t}\n\t\t\tfor _, name := range []string{\"spec\", \"format\", \"content\"} {\n\t\t\t\tif len(fields[name]) == 0 || bytes.Equal(bytes.TrimSpace(fields[name]), []byte(\"null\")) {\n\t\t\t\t\treturn fmt.Errorf(\"missing table cell rich text field [%s]\", name)\n\t\t\t\t}\n\t\t\t}\n\t\t\tvar rich ast.TableCellRich\n\t\t\tif err := json.Unmarshal(node.TableCellRich, &rich); nil != err {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif _, err := av.ParseTableCellRich(&rich); nil != err {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/treenode/table_cell_rich.go#L19-L55","documentation":"A NodeTableCell carrying rich text is only legal in a document whose spec version is >= 4, with the node type NodeTableCell, while walking inside a table row context. If any of these conditions fails (e.g. the document declares an older spec but still embeds TableCellRich), this error is thrown with the offending spec string.","triggerScenarios":"checkTableCellRichJSON encounters TableCellRich on a node when the document spec is \"3\" or lower, the node type is not \"NodeTableCell\", or the walk context is not \"row\" (e.g. cell data placed outside a row).","commonSituations":"Importing a newer-format document into an older kernel version that declares a lower spec; a generator emitting TableCellRich on wrong node types or outside table rows; hand-edited .sy files.","solutions":["Use a kernel version that supports TableCellRichDocumentSpec \"4\" or later.","Ensure the document's spec attribute is \"4\" wherever TableCellRich is present.","Fix the producer so TableCellRich appears only on NodeTableCell nodes inside table rows."],"exampleFix":"// before (producer)\nspec = \"3\"; node.TableCellRich = rich\n// after\nspec = \"4\"; node.Type = \"NodeTableCell\"; node.TableCellRich = rich // emitted under a row","handlingStrategy":"validation","validationCode":"if parseInt(docSpec) < 4 && docContainsTableCellRich(doc) { /* upgrade producer/kernel or strip rich text before loading */ }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Match producer spec version to the kernel's TableCellRichDocumentSpec (\"4\").","Emit TableCellRich only on NodeTableCell inside table rows.","Keep kernel and data-producing tools on compatible versions."],"tags":["tables","rich-text","versioning","spec"],"backgroundTag":"schema-validation-failed","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}