{"record":{"id":"735d372897b746be","repo":"siyuan-note/siyuan","slug":"missing-table-cell-rich-text-field-s","errorCode":null,"errorMessage":"missing table cell rich text field [%s]","messagePattern":"missing table cell rich text field \\[(.+?)\\]","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/treenode/table_cell_rich.go","lineNumber":45,"sourceCode":"\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}\n\t\tchildContext := \"\"\n\t\tswitch node.Type {\n\t\tcase \"NodeTable\":\n\t\t\tchildContext = \"table\"\n\t\tcase \"NodeTableHead\":\n\t\t\tif context == \"table\" {\n\t\t\t\tchildContext = \"head\"\n\t\t\t}","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/treenode/table_cell_rich.go#L27-L63","documentation":"After the field-count check, each of the three required TableCellRich fields (spec, format, content) must be present, non-empty, and not JSON null. A missing/empty/null field yields this error naming the field.","triggerScenarios":"A TableCellRich payload object containing keys with empty values, explicit null, or omitting one of spec/format/content entirely, e.g. {\"spec\":\"4\",\"format\":\"\",\"content\":\"x\"}.","commonSituations":"Producers that write empty strings for unset fields, serialization dropping default values, or partial writes/truncation leaving a field null.","solutions":["Populate all three fields with non-null values: spec (e.g. \"4\"), a valid format identifier, and the cell content string.","Fix the generating code so it never emits empty/null for these fields.","Restore the affected document from snapshot/history if the null fields come from data corruption."],"exampleFix":"// before\n{\"spec\":\"4\",\"format\":null,\"content\":\"x\"}\n// after\n{\"spec\":\"4\",\"format\":\"markdown\",\"content\":\"x\"}","handlingStrategy":"validation","validationCode":"if (!payload.spec || !payload.format || payload.content == null) { /* reject before writing */ }","typeGuard":"function hasAllRichFields(v) {\n  return typeof v === 'object' && v !== null &&\n    v.spec != null && v.spec !== '' && v.format != null && v.format !== '' && v.content != null;\n}","tryCatchPattern":null,"preventionTips":["Always populate spec, format, and content with non-empty values.","Disable serializers that drop empty/default fields for this struct.","Validate payloads at write time, not only at load time."],"tags":["tables","rich-text","schema","empty-field"],"backgroundTag":"empty-required-field","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"}