{"record":{"id":"62e058d62dbd987b","repo":"siyuan-note/siyuan","slug":"table-cell-rich-text-is-missing","errorCode":null,"errorMessage":"table cell rich text is missing","messagePattern":"table cell rich text is missing","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/av/table_cell_rich.go","lineNumber":14,"sourceCode":"package av\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n\n\t\"github.com/88250/lute/ast\"\n\t\"github.com/88250/lute/parse\"\n)\n\n// ParseTableCellRich 复用数据库片段的格式校验，并保留普通表格已有的图片能力。\nfunc ParseTableCellRich(rich *ast.TableCellRich) (*parse.Tree, error) {\n\tif nil == rich {\n\t\treturn nil, fmt.Errorf(\"table cell rich text is missing\")\n\t}\n\tif err := rich.Validate(); nil != err {\n\t\treturn nil, err\n\t}\n\t_, tree, err := parseValueTextRichWithImages(&ValueTextRich{\n\t\tSpec: rich.Spec, Format: ValueTextRichFormat(rich.Format), Content: rich.Content,\n\t}, true)\n\treturn tree, err\n}\n\n// RenderTableCellRich 将已校验的片段写回稳定的富文本源。\nfunc RenderTableCellRich(tree *parse.Tree) (string, error) {\n\tif err := validateValueTextRichTreeWithImages(tree, true); nil != err {\n\t\treturn \"\", err\n\t}\n\tcontent, _, err := normalizeValueTextRichTreeSourceWithImages(tree, true)\n\treturn content, err\n}","sourceCodeStart":1,"sourceCodeEnd":32,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/av/table_cell_rich.go#L1-L32","documentation":"ParseTableCellRich converts a database (attribute view) table-cell rich-text fragment into a parse tree, reusing the database fragment validation while keeping image support of regular tables. It requires a non-nil ast.TableCellRich; passing nil returns 'table cell rich text is missing' because there is nothing to parse or validate.","triggerScenarios":"Calling ParseTableCellRich(nil) — typically when a table cell has no rich-text payload (TableCellRich pointer unset) and the caller forwards it unconditionally, e.g. during table rendering or the asset-reference synchronization tested in TestTableCellRichSynchronizesAssetReferenceAndText.","commonSituations":"Rendering tables where some cells come from a database snippet and others from plain markdown, so only some cells carry TableCellRich; refactors that changed cell optional handling; plugins exporting tables that assume every cell has rich content.","solutions":["Check the cell for a nil TableCellRich and skip ParseTableCellRich, rendering the plain content instead","Ensure the upstream table parsing actually populates TableCellRich for database cells","Return/propagate an empty tree for nil input in the caller instead of an error","Log and fall back to plain-text rendering"],"exampleFix":"// before\ntree, err := av.ParseTableCellRich(cell.Rich)\n// after\nif cell.Rich == nil {\n    continue // plain cell, nothing to parse\n}\ntree, err := av.ParseTableCellRich(cell.Rich)","handlingStrategy":"type-guard","validationCode":"if cell.Rich == nil {\n    return nil // nothing to parse\n}","typeGuard":"func hasRich(cell *ast.TableCell) bool { return cell != nil && cell.Rich != nil }","tryCatchPattern":"tree, err := av.ParseTableCellRich(cell.Rich)\nif err != nil {\n    if err.Error() == \"table cell rich text is missing\" {\n        return renderPlain(cell), nil\n    }\n    return err\n}","preventionTips":["Nil-check TableCellRich before parsing; it is optional per cell","Handle mixed tables (plain markdown cells vs database snippet cells)","Add regression tests for cells without rich content"],"tags":["attribute-view","table","nil-value"],"backgroundTag":"null-argument","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"}