siyuan-note/siyuan · error

Conf.Language(118)

Error message

Conf.Language(118)

What it means

validateLocations checks each planned document's filesystem depth before the doc tree is created. SiYuan limits documents to 7 path segments unless FileTree.AllowCreateDeeper is enabled; if any node's path has more than 7 slashes and the setting is off, creation aborts with the localized message Conf.Language(118) (the standard "maximum levels of docs" warning). This is a config-dependent depth validation, not a parse error.

Source

Thrown at kernel/model/template_doc_tree.go:294

}

func flattenTemplateDocTreeNodes0(nodes []*TemplateDocTreeNode) (ret []*TemplateDocTreeNode) {
	for _, node := range nodes {
		ret = append(ret, node)
		ret = append(ret, flattenTemplateDocTreeNodes0(node.Children)...)
	}
	return
}

func (collector *templateDocTreeCollector) validateLocations() error {
	box := Conf.Box(collector.boxID)
	if nil == box {
		return ErrBoxNotFound
	}
	allowCreateDeeper := nil != Conf.FileTree && Conf.FileTree.AllowCreateDeeper
	for _, node := range flattenTemplateDocTreeNodes0(collector.nodes) {
		if depth := strings.Count(node.path, "/"); 7 < depth && !allowCreateDeeper {
			return errors.New(Conf.Language(118))
		}
		if box.Exist(node.path) {
			return fmt.Errorf("document path [%s] already exists", node.path)
		}
	}
	return nil
}

func (collector *templateDocTreeCollector) buildTree(node *TemplateDocTreeNode, renderedTree *parse.Tree) {
	renderedRootID := renderedTree.Root.ID
	renderedTree.Box = collector.boxID
	renderedTree.Path = node.path
	renderedTree.HPath = node.HPath
	renderedTree.ID = node.ID
	renderedTree.Root.ID = node.ID
	renderedTree.Root.Spec = treenode.CurrentSpec
	templateIALs := parse.IAL2Map(renderedTree.Root.KramdownIAL)
	renderedTree.Root.KramdownIAL = [][]string{

View on GitHub (pinned to 8641553a1f)

Solutions

  1. Enable deep document creation: 设置 - 文件树 - 允许建立深层文档 (FileTree.AllowCreateDeeper).
  2. Flatten the createDocTree definition so no document is nested more than 7 levels.
  3. Move the target document to a shorter parent path to reduce resulting depth.

Example fix

// before (conf)
FileTree.AllowCreateDeeper = false  // template nests 9 levels
// after
FileTree.AllowCreateDeeper = true, or flatten the definition to <= 7 levels
Defensive patterns

Strategy: validation

Validate before calling

// check depth (path slash count) against the workspace setting before rendering
const maxDepth = window?.siyuan?.conf?.fileTree?.allowCreateDeeper ? Infinity : 7;
const tooDeep = flatten(nodes).some((n) => n.path.split("/").length - 1 > maxDepth);

Try / catch

try {
  await insertTemplateWithDocTree(def);
} catch (e) {
  if (e && e.code === 118 || /深层|deeper|levels/i.test(String(e.msg || e))) {
    // prompt user to enable deep docs or flatten the tree
  }
}

Prevention

When it happens

Trigger: Inserting a template whose createDocTree definition nests children deeper than 7 path levels in a notebook/workspace where "Allow create deeper docs" (设置 - 文件树 - 允许建立深层文档) is disabled.

Common situations: Deeply nested outlines (e.g. year/quarter/month/week/day topics), templates copied from users who had deep-docs enabled, multi-tenant sync where one workspace allows deep docs and another does not.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


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