{"record":{"id":"92bddb6e27bfaaf1","repo":"siyuan-note/siyuan","slug":"unsupported-renderdocref-query-mode-s","errorCode":null,"errorMessage":"unsupported renderDocRef query mode [%s]","messagePattern":"unsupported renderDocRef query mode \\[(.+?)\\]","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/template_doc_tree.go","lineNumber":274,"sourceCode":"\t\t\t\treturn node.Children, nil\n\t\t\t}\n\t\t}\n\t\treturn []*TemplateDocTreeNode{}, nil\n\tcase \"path\":\n\t\thPath, ok := value.(string)\n\t\tif !ok {\n\t\t\treturn \"\", errors.New(\"renderDocRef path target must be a document path\")\n\t\t}\n\t\trequestedPath := path.Clean(hPath)\n\t\tfor _, node := range flattenTemplateDocTreeNodes0(collector.nodes) {\n\t\t\trelativePath := strings.TrimPrefix(node.HPath, collector.rootHPath)\n\t\t\tif node.HPath == requestedPath || relativePath == requestedPath {\n\t\t\t\treturn fmt.Sprintf(\"((%s %q))\", node.RootID, node.HPath), nil\n\t\t\t}\n\t\t}\n\t\treturn \"\", nil\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"unsupported renderDocRef query mode [%s]\", mode)\n\t}\n}\n\nfunc flattenTemplateDocTreeNodes0(nodes []*TemplateDocTreeNode) (ret []*TemplateDocTreeNode) {\n\tfor _, node := range nodes {\n\t\tret = append(ret, node)\n\t\tret = append(ret, flattenTemplateDocTreeNodes0(node.Children)...)\n\t}\n\treturn\n}\n\nfunc (collector *templateDocTreeCollector) validateLocations() error {\n\tbox := Conf.Box(collector.boxID)\n\tif nil == box {\n\t\treturn ErrBoxNotFound\n\t}\n\tallowCreateDeeper := nil != Conf.FileTree && Conf.FileTree.AllowCreateDeeper\n\tfor _, node := range flattenTemplateDocTreeNodes0(collector.nodes) {","sourceCodeStart":256,"sourceCodeEnd":292,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/model/template_doc_tree.go#L256-L292","documentation":"renderDocRef supports exactly two query modes: \"children\" and \"path\". Any other mode string reaches the default branch of the switch and fails with \"unsupported renderDocRef query mode [<mode>]\". This is an explicit enumeration guard rather than silent fallback.","triggerScenarios":"Calling renderDocRef(\"parent\", ...), renderDocRef(\"siblings\", ...), renderDocRef(\"Children\", ...) (case-sensitive), or a misspelled mode like renderDocRef(\"child\", ...).","commonSituations":"Assuming the API supports more query modes than implemented; capitalization typos; copying pseudo-code from docs or issues describing wished-for modes.","solutions":["Use only \"children\" or \"path\" as the mode string, lowercase.","If you need other lookups (parent/siblings), use node fields from the children result (each node carries ParentID/RootID/HPath).","Check spelling and case of the mode argument."],"exampleFix":"// before\nrenderDocRef(\"Children\", rootID)\n// after\nrenderDocRef(\"children\", rootID)","handlingStrategy":"validation","validationCode":"const MODES = [\"children\", \"path\"];\nif (!MODES.includes(mode)) throw new Error(`unsupported renderDocRef mode: ${mode}`);","typeGuard":"const isRenderDocRefMode = (v) => v === \"children\" || v === \"path\";","tryCatchPattern":"try {\n  const out = renderDocRef(mode, value);\n} catch (e) {\n  if (/unsupported renderDocRef query mode/.test(String(e))) {\n    // map legacy mode names to children/path before retrying\n  }\n}","preventionTips":["Keep a whitelist constant of the two valid modes","Watch case sensitivity — modes are lowercase","Add schema validation on template inputs"],"tags":["template","invalid-enum","argument"],"backgroundTag":"invalid-enum-value","analyzedSha":"8641553a1f07374001902d3ce773285db1292b2d","analyzedAt":"2026-09-11T16:08:28.414Z","contentChangedAt":"2026-09-11T16:08:28.414Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}