siyuan-note/siyuan · error

unsupported renderDocRef query mode

Error message

unsupported renderDocRef query mode [%s]

What it means

renderDocRef supports only the modes 'children' and 'path'. Any other mode string reaches the default branch of the switch and is rejected with this error naming the unsupported mode. It is a guard against typos and future/unknown mode names in templates.

Solutions

  1. Change the mode to "children" (query children by document ID) or "path" (resolve a block ref by document path)
  2. Fix typos in the template's renderDocRef action
  3. Check the supported mode list in kernel/model/template_doc_tree.go renderDocRef

Example fix

// before
{{renderDocRef "childrens" "20240101120000-abcdefg"}}
// after
{{renderDocRef "children" "20240101120000-abcdefg"}}
Defensive patterns

Strategy: validation

Validate before calling

var validModes = map[string]bool{"children": true, "path": true}
if !validModes[mode] { return fmt.Errorf("unsupported mode %q", mode) }

Try / catch

out, err := collector.renderDocRef(mode, value)
if err != nil && strings.Contains(err.Error(), "unsupported renderDocRef query mode") {
  // correct the mode name in the template
}

Prevention

When it happens

Trigger: A template action calls renderDocRef with a mode other than "children" or "path" — typically a typo like "child", "byPath", or a mode invented by the template author.

Common situations: Typos in template files; copying action syntax from a different template subsystem with different mode names; older templates using mode names that were never supported.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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

Appendix: source

Thrown at kernel/model/template_doc_tree.go:274

				return node.Children, nil
			}
		}
		return []*TemplateDocTreeNode{}, nil
	case "path":
		hPath, ok := value.(string)
		if !ok {
			return "", errors.New("renderDocRef path target must be a document path")
		}
		requestedPath := path.Clean(hPath)
		for _, node := range flattenTemplateDocTreeNodes0(collector.nodes) {
			relativePath := strings.TrimPrefix(node.HPath, collector.rootHPath)
			if node.HPath == requestedPath || relativePath == requestedPath {
				return fmt.Sprintf("((%s %q))", node.RootID, node.HPath), nil
			}
		}
		return "", nil
	default:
		return nil, fmt.Errorf("unsupported renderDocRef query mode [%s]", mode)
	}
}

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) {

View on GitHub (pinned to 9f775e8a12)