siyuan-note/siyuan · error

data block DOM failed: %w

Error message

data block DOM failed: %w

What it means

Returned by parseBlockUpdateData when dataType == "markdown" and DataBlockDOM(data, luteEngine) returned a non-nil error. The wrapped error (%w) carries the underlying Lute/parse cause. The input could not be converted from markdown to the SiYuan DOM representation.

Source

Thrown at kernel/model/block_update.go:209

				invalidID = n.ID
				return ast.WalkStop
			}
			return ast.WalkContinue
		})
	}
	if "" != invalidID {
		return "", errors.New("found invalid ID [" + invalidID + "]")
	}
	return
}

func parseBlockUpdateData(data, dataType string, luteEngine *lute.Lute) (ret string, tree *parse.Tree, err error) {
	ret = data
	switch dataType {
	case "markdown":
		ret, err = DataBlockDOM(data, luteEngine)
		if err != nil {
			err = fmt.Errorf("data block DOM failed: %w", err)
			return
		}
	case "dom":
	default:
		err = fmt.Errorf("unsupported block data type [%s]", dataType)
		return
	}

	tree = luteEngine.BlockDOM2Tree(ret)
	if nil == tree || nil == tree.Root || nil == firstContentBlock(tree.Root) {
		err = errors.New("parse tree failed")
	}
	return
}

func normalizeBlockUpdateTree(oldNode *ast.Node, tree *parse.Tree, luteEngine *lute.Lute) (ret *parse.Tree, updatedNode *ast.Node, err error) {
	updatedNode, err = resolveBlockUpdateNode(oldNode, tree.Root)
	if err != nil {

View on GitHub (pinned to 251596fc0d)

Solutions

  1. Inspect the wrapped error for the specific Lute parse message.
  2. Reduce the input to a minimal repro and isolate the offending markdown fragment.
  3. Sanitize/normalize the markdown (e.g. via a linter) before submission.
  4. If the input is already DOM, switch dataType to "dom" to skip the markdown-to-DOM step.
Defensive patterns

Strategy: try-catch

Validate before calling

// minimal sanity check on markdown before sending
if strings.Count(md, "```")%2 != 0 {
    return errors.New("unbalanced code fences")
}

Try / catch

ops, roots, err := buildBlockUpdateOperations(inputs, resolver, loader)
if err != nil {
    if cause := errors.Unwrap(err); cause != nil && strings.Contains(cause.Error(), "markdown") {
        // narrow to minimal repro and surface cause to user
    }
}

Prevention

When it happens

Trigger: Malformed markdown (unbalanced code fences, broken inline math, unsupported syntax); very large input that exceeds Lute limits; encoding issues (non-UTF-8 bytes).

Common situations: Pasted markdown from a tool that emits non-standard syntax; programmatic generation producing half-formed markdown; encoding mismatch in the transport layer.

Related errors


AI-assisted analysis of siyuan-note/siyuan@251596fc0d (2026-08-12). Data as JSON: /api/errors/59f3086ebd696d92. Report an issue: GitHub.