siyuan-note/siyuan · error

table cell rich text is missing

Error message

table cell rich text is missing

What it means

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.

Solutions

  1. Check the cell for a nil TableCellRich and skip ParseTableCellRich, rendering the plain content instead
  2. Ensure the upstream table parsing actually populates TableCellRich for database cells
  3. Return/propagate an empty tree for nil input in the caller instead of an error
  4. Log and fall back to plain-text rendering

Example fix

// before
tree, err := av.ParseTableCellRich(cell.Rich)
// after
if cell.Rich == nil {
    continue // plain cell, nothing to parse
}
tree, err := av.ParseTableCellRich(cell.Rich)
Defensive patterns

Strategy: type-guard

Validate before calling

if cell.Rich == nil {
    return nil // nothing to parse
}

Type guard

func hasRich(cell *ast.TableCell) bool { return cell != nil && cell.Rich != nil }

Try / catch

tree, err := av.ParseTableCellRich(cell.Rich)
if err != nil {
    if err.Error() == "table cell rich text is missing" {
        return renderPlain(cell), nil
    }
    return err
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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

Appendix: source

Thrown at kernel/av/table_cell_rich.go:14

package av

import (
	"fmt"
	"strings"

	"github.com/88250/lute/ast"
	"github.com/88250/lute/parse"
)

// ParseTableCellRich 复用数据库片段的格式校验,并保留普通表格已有的图片能力。
func ParseTableCellRich(rich *ast.TableCellRich) (*parse.Tree, error) {
	if nil == rich {
		return nil, fmt.Errorf("table cell rich text is missing")
	}
	if err := rich.Validate(); nil != err {
		return nil, err
	}
	_, tree, err := parseValueTextRichWithImages(&ValueTextRich{
		Spec: rich.Spec, Format: ValueTextRichFormat(rich.Format), Content: rich.Content,
	}, true)
	return tree, err
}

// RenderTableCellRich 将已校验的片段写回稳定的富文本源。
func RenderTableCellRich(tree *parse.Tree) (string, error) {
	if err := validateValueTextRichTreeWithImages(tree, true); nil != err {
		return "", err
	}
	content, _, err := normalizeValueTextRichTreeSourceWithImages(tree, true)
	return content, err
}

View on GitHub (pinned to 9f775e8a12)