siyuan-note/siyuan · error

createDocTree document title is required

Error message

createDocTree document title is required

What it means

Every document entry in a createDocTree definition must carry a title field, which becomes the child document's name and hierarchical path segment. parseNodes throws this when the title key is absent from a document object. Without a title the kernel cannot place the new document in the tree.

Solutions

  1. Add a "title" string field to every document object in the createDocTree definition.
  2. Verify each entry in the list (including nested children entries) has title.
  3. If the title should come from rendered content, compute it in the template before invoking createDocTree.

Example fix

// before
[{"template": "daily.md", "children": []}]
// after
[{"title": "2026-09-18", "template": "daily.md", "children": []}]
Defensive patterns

Strategy: validation

Validate before calling

function hasTitle(doc) {
  return typeof doc.title === "string";
}
const ok = docs.every(d => hasTitle(d));

Type guard

const isDocWithTitle = (d) => typeof d === 'object' && d !== null && typeof d.title === 'string';

Prevention

When it happens

Trigger: A document object in the createDocTree list omits "title" entirely, e.g. {"template": "tpl.md"} or {"children": [...]}. Triggered via parseTemplateDocTreeDefinition when a template is manually inserted in the editor.

Common situations: Templates that only specify content template/define assuming a title is auto-derived; programmatically generated definition lists missing the title key; templates copied from examples that showed title as optional.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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

Appendix: source

Thrown at kernel/model/template_doc_tree.go:149

	}

	nodes := make([]*TemplateDocTreeNode, 0, len(values))
	for _, value := range values {
		definition, ok := value.(map[string]any)
		if !ok {
			return nil, errors.New("createDocTree document must be a dictionary")
		}
		for key := range definition {
			switch key {
			case "title", "template", "define", "children":
			default:
				return nil, fmt.Errorf("createDocTree document contains unknown field [%s]", key)
			}
		}

		titleValue, ok := definition["title"]
		if !ok {
			return nil, errors.New("createDocTree document title is required")
		}
		title, ok := titleValue.(string)
		if !ok {
			return nil, errors.New("createDocTree document title must be a string")
		}
		title = normalizeDocTitle(title)
		if "" == title {
			return nil, errors.New("createDocTree document title must not be empty")
		}
		if 512 < utf8.RuneCountInString(title) {
			return nil, fmt.Errorf("createDocTree document title exceeds %d characters", 512)
		}

		templateName, err := templateDocTreeStringField(definition, "template")
		if nil != err {
			return nil, err
		}
		defineName, err := templateDocTreeStringField(definition, "define")

View on GitHub (pinned to 9f775e8a12)