siyuan-note/siyuan · error · Error

Invalid table cell rich text payload

Error message

Invalid table cell rich text payload

What it means

Guard in decodeTableCellRich: the encoded attribute string contains characters outside the base64url alphabet, so it is not a validly encoded table-cell rich-text payload — the data-sy-table-cell-rich attribute was corrupted or hand-edited.

Solutions

  1. Edit the table cell to rewrite its rich text content
  2. Remove the invalid data-sy-table-cell-rich attribute
  3. Restore the document from history
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at app/src/protyle/util/tableCellRichValue.ts:19 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at app/src/protyle/util/tableCellRichValue.ts:19

export const TABLE_CELL_RICH_ATTRIBUTE = "data-sy-table-cell-rich";
export const TABLE_RICH_ATTRIBUTE = "custom-sy-table-rich";

export interface TableCellRich {
    spec: 1;
    format: "kramdown";
    content: string;
}

export const encodeTableCellRich = (content: string) => {
    const bytes = new TextEncoder().encode(JSON.stringify({spec: 1, format: "kramdown", content}));
    let binary = "";
    bytes.forEach(byte => binary += String.fromCharCode(byte));
    return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
};

export const decodeTableCellRich = (encoded: string): TableCellRich => {
    if (!/^[A-Za-z0-9_-]+$/.test(encoded)) {
        throw new Error("Invalid table cell rich text payload");
    }
    const bytes = Uint8Array.from(atob(encoded.replace(/-/g, "+").replace(/_/g, "/")), char => char.charCodeAt(0));
    const value = JSON.parse(new TextDecoder("utf-8", {fatal: true}).decode(bytes));
    if (!value || Object.keys(value).length !== 3 || value.spec !== 1 || value.format !== "kramdown" ||
        typeof value.content !== "string" || value.content.includes("\u0000")) {
        throw new Error("Unsupported table cell rich text format");
    }
    return value;
};

View on GitHub (pinned to 9f775e8a12)