siyuan-note/siyuan · error

empty IFrame block

Error message

empty IFrame block

What it means

htmlAssetIFrameBlockDOM renders a sandboxed iframe snippet to a block DOM tree via Lute (markdownToBlockDOM then BlockDOM2Tree) and requires the resulting tree to contain at least one node under Root. An empty tree/nil root means the parser produced no block for the iframe markup, so no block ID can be extracted.

Solutions

  1. Verify the Go lute library and lute.min.js are current and in sync so iframe HTML blocks parse into a tree
  2. Log the dom string returned by markdownToBlockDOM before parsing to see whether the renderer produced empty output
  3. Check the error returned by markdownToBlockDOM first — a rendering failure upstream is the usual root cause
  4. Add a regression test rendering a minimal iframe to catch Lute behavior changes

Example fix

// before
dom, err := markdownToBlockDOM(iframeMarkdown) // err ignored upstream, empty dom
// after
if dom == "" || err != nil {
    return "", "", fmt.Errorf("markdown render failed: %w", err)
}
tree := util.NewLute().BlockDOM2Tree(dom)
Defensive patterns

Strategy: try-catch

Validate before calling

tree := util.NewLute().BlockDOM2Tree(dom)
if tree == nil || tree.Root == nil || tree.Root.FirstChild == nil {
    return fmt.Errorf("lute produced an empty tree for iframe dom")
}

Try / catch

blockID, _, err := htmlAssetIFrameBlockDOM()
if err != nil && strings.Contains(err.Error(), "empty IFrame block") {
    // check Lute version / markdown renderer output before retry
}

Prevention

When it happens

Trigger: markdownToBlockDOM fails or returns markup that BlockDOM2Tree parses into a tree with nil Root or no FirstChild — typically a Lute rendering failure or version mismatch for raw HTML/iframe blocks, surfaced through assetCreateHTML.

Common situations: A Lute (lute.min.js / Go lute) version where iframe HTML is stripped or parsed differently; corrupted or uninitialized Lute instance in tests; markdown pipeline changes dropping raw HTML blocks.

Understand the failure class

Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.

Related errors


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

Appendix: source

Thrown at kernel/mcp/tools/asset.go:189

		name = "component.html"
	}
	name = filepath.Base(name)
	ext := strings.ToLower(filepath.Ext(name))
	if ext != ".html" && ext != ".htm" {
		return "", fmt.Errorf("name must end in .html or .htm")
	}
	return name, nil
}

func htmlAssetIFrameBlockDOM(assetPath string) (dom, blockID string, err error) {
	src := html.EscapeString(model.HTMLAssetIFrameSrc(assetPath))
	dom, err = markdownToBlockDOM(`<iframe sandbox="allow-scripts" src="` + src + `" border="0" frameborder="no" framespacing="0" allowfullscreen="true"></iframe>`)
	if err != nil {
		return
	}
	tree := util.NewLute().BlockDOM2Tree(dom)
	if tree == nil || tree.Root == nil || tree.Root.FirstChild == nil {
		return "", "", fmt.Errorf("empty IFrame block")
	}
	blockID = tree.Root.FirstChild.ID
	return
}

func newAssetUploadToolResult(succeeded []model.AssetUploadSuccess, failed []model.AssetUploadFailure) CallToolResult {
	var sb strings.Builder
	sb.WriteString(fmt.Sprintf("Uploaded %d file(s):\n", len(succeeded)))
	for _, result := range succeeded {
		sb.WriteString(fmt.Sprintf("- %s -> %s\n", result.Name, result.Path))
	}
	if 0 < len(failed) {
		sb.WriteString(fmt.Sprintf("\nFailed %d file(s):\n", len(failed)))
		for _, result := range failed {
			sb.WriteString(fmt.Sprintf("- %s: %s\n", result.Name, result.Error))
		}
	}
	return CallToolResult{Content: []ContentItem{{Type: "text", Text: sb.String()}}, IsError: 0 < len(failed)}

View on GitHub (pinned to 9f775e8a12)