siyuan-note/siyuan · error

Conf.Language(16)

Error message

Conf.Language(16)

What it means

In validateCreateDoc, after the title defaults to the localized 'Untitled' (key 16) when empty, the kernel validates the target path: it takes path.Base(p) and runs util.GetTreeID(baseName). If the base name does not contain a valid tree ID (the trailing 14-hex-digit timestamp-id suffix), the path cannot map to a document, so it returns errors.New(Conf.Language(16)). Here key 16's text ('Untitled') is repurposed as a generic invalid-doc-path message.

Source

Thrown at kernel/model/file.go:2288

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 8641553a1f)

Solutions

  1. Generate a valid doc path first by calling /api/filetree/getID (or create docs via createDocWithMd using paths issued by the API)
  2. Append a proper ID in the form '<name>-YYYYMMDDhhmmss' plus check suffix to the path base
  3. Use the frontend's idgen/utility so the base name contains a valid tree ID
  4. Pass an existing parent path plus title and let the kernel compose the child path

Example fix

// before
await fetchPost('/api/filetree/createDocWithMd', {notebook, path: '/My Note', markdown});
// after
const id = await fetchPost('/api/filetree/getID', {}); // returns e.g. '20230815102030-abc1234'
await fetchPost('/api/filetree/createDocWithMd', {notebook, path: '/My Note-' + id, markdown});
Defensive patterns

Strategy: validation

Validate before calling

function hasValidTreeID(baseName) {
  // base must end with '-YYYYMMDDhhmmss-xxxxxx' style ID; empty GetTreeID means invalid
  return /-\d{14}-[0-9a-f]{7}$/i.test(baseName);
}

Try / catch

try {
  await fetchPost('/api/filetree/createDocWithMd', {notebook, path, markdown});
} catch (e) {
  if (String(e).includes('Untitled')) {
    // regenerate path with a fresh ID and retry
  }
}

Prevention

When it happens

Trigger: POST /api/filetree/createDocWithMd (or createDoc) where the path's base segment lacks a valid block/document ID suffix — e.g. path '/foo' or '/foo-bar' without '-20230801...' ID, or an empty/malformed baseName.

Common situations: Scripts that build the path from a human-readable name only instead of 'name-YYYYMMDDhhmmss-xx' format (e.g. via /api/filetree/getID or generateDocID); plugins copying paths between notebooks without re-issuing IDs; hand-edited paths with lost ID suffixes.

Understand the failure class

Background: "invalid id" errors: invalid identifier format — why libraries reject IDs before lookup, and how to fix them — this error's family across 37 libraries.

Related errors


AI-assisted analysis of siyuan-note/siyuan@8641553a1f (2026-09-11). Data as JSON: /api/errors/dbaea746d46f6e27. Report an issue: GitHub.