siyuan-note/siyuan · error

Untitled

Error message

Untitled

What it means

Thrown by validateCreateDoc when the path's base filename yields no valid tree ID via util.GetTreeID(baseName). Conf.Language(16) = 'Untitled'. This means the filename portion of the document path doesn't contain a parseable SiYuan block ID (the YYYYMMDDHHmmss-xxxxxx format). The function cannot proceed because the document ID is derived from the path.

Source

Thrown at kernel/model/file.go:2261

func validateCreateDoc(boxID, p, title string, titleEmpty bool) (ret *createDocValidation, err error) {
	p = normalizeBoxDocPath(boxID, p)
	title = normalizeDocTitle(title)
	if 512 < utf8.RuneCountInString(title) {
		// 限制笔记本名和文档名最大长度为 `512` https://github.com/siyuan-note/siyuan/issues/6299
		return nil, errors.New(Conf.Language(106))
	}

	isEmpty := false
	if "" == title {
		title = Conf.Language(16)
		isEmpty = true
	} else if titleEmpty {
		isEmpty = true
	}

	baseName := strings.TrimSpace(path.Base(p))
	if "" == util.GetTreeID(baseName) {
		return nil, errors.New(Conf.Language(16))
	}
	if strings.HasPrefix(baseName, ".") {
		return nil, errors.New(Conf.Language(13))
	}

	box, boxErr := getOpenedBox(boxID)
	if nil != boxErr {
		return nil, boxErr
	}

	folder := path.Dir(p)
	hPath := "/" + title
	if "/" != folder {
		parentID := path.Base(folder)
		parentTree, loadErr := LoadTreeByBlockID(parentID)
		if nil != loadErr {
			logging.LogErrorf("get parent tree [%s] failed", parentID)
			return nil, ErrBlockNotFound

View on GitHub (pinned to 251596fc0d)

Solutions

  1. Generate a valid SiYuan ID using the ID-generation utility and use it as the path base name (e.g., /folder/20240101120000-abcdefg.sy).
  2. If you only have a title, let the kernel generate the ID — pass an appropriate path constructed from the generated ID.
  3. Pre-validate: ensure util.GetTreeID(path.Base(p)) returns a non-empty string before calling create functions.
  4. For API consumers, use the create-with-markdown endpoint that auto-generates IDs if you don't supply one.

Example fix

// before
p := "/notes/my-document.sy"
err := model.ValidateCreateDoc(boxID, p, title)

// after
id := util.GetTreeID(path.Base(p))
if id == "" {
    // generate a proper SiYuan ID for the path
    newID := util.NewNodeID() // or the kernel's ID generator
    p = path.Join(path.Dir(p), newID+".sy")
}
err := model.ValidateCreateDoc(boxID, p, title)
Defensive patterns

Strategy: validation

Validate before calling

// Pre-check: ensure path base name yields a valid tree ID
baseName := strings.TrimSpace(path.Base(p))
if util.GetTreeID(baseName) == "" {
    // generate a valid SiYuan ID for the path
    newID := util.NewNodeID()
    p = path.Join(path.Dir(p), newID+".sy")
}

Type guard

func hasValidTreeID(p string) bool {
    baseName := strings.TrimSpace(path.Base(p))
    return util.GetTreeID(baseName) != ""
}

Prevention

When it happens

Trigger: Calling create/validate functions with a path whose base name is not a valid SiYuan ID format. For example, path='/folder/mydoc.sy' instead of '/folder/20240101120000-abcdefg.sy'. The GetTreeID function extracts the ID suffix; if it returns empty, the path is malformed.

Common situations: A programmatic caller constructs a path with a human-readable filename instead of a SiYuan-format ID. A migration script creates paths without generating proper IDs. The path was manually built without using util.GetTreeID or the ID-generation utility.

Related errors


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