{"record":{"id":"815d7651850930ed","repo":"siyuan-note/siyuan","slug":"createdoctree-document-contains-unknown-field-s","errorCode":null,"errorMessage":"createDocTree document contains unknown field [%s]","messagePattern":"createDocTree document contains unknown field \\[(.+?)\\]","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/template_doc_tree.go","lineNumber":143,"sourceCode":"\tvalues, ok := value.([]any)\n\tif !ok {\n\t\treturn nil, errors.New(\"createDocTree definition must be a list\")\n\t}\n\tif 0 == len(values) {\n\t\treturn nil, errors.New(\"createDocTree document list must not be empty\")\n\t}\n\n\tnodes := make([]*TemplateDocTreeNode, 0, len(values))\n\tfor _, value := range values {\n\t\tdefinition, ok := value.(map[string]any)\n\t\tif !ok {\n\t\t\treturn nil, errors.New(\"createDocTree document must be a dictionary\")\n\t\t}\n\t\tfor key := range definition {\n\t\t\tswitch key {\n\t\t\tcase \"title\", \"template\", \"define\", \"children\":\n\t\t\tdefault:\n\t\t\t\treturn nil, fmt.Errorf(\"createDocTree document contains unknown field [%s]\", key)\n\t\t\t}\n\t\t}\n\n\t\ttitleValue, ok := definition[\"title\"]\n\t\tif !ok {\n\t\t\treturn nil, errors.New(\"createDocTree document title is required\")\n\t\t}\n\t\ttitle, ok := titleValue.(string)\n\t\tif !ok {\n\t\t\treturn nil, errors.New(\"createDocTree document title must be a string\")\n\t\t}\n\t\ttitle = normalizeDocTitle(title)\n\t\tif \"\" == title {\n\t\t\treturn nil, errors.New(\"createDocTree document title must not be empty\")\n\t\t}\n\t\tif 512 < utf8.RuneCountInString(title) {\n\t\t\treturn nil, fmt.Errorf(\"createDocTree document title exceeds %d characters\", 512)\n\t\t}","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/template_doc_tree.go#L125-L161","documentation":"The createDocTree template action validates each document object in the definition list. Only the fields title, template, define, and children are recognized; any other key causes parseNodes to reject the whole definition. This strict whitelist prevents typos from silently being ignored and producing unintended document trees.","triggerScenarios":"Calling the createDocTree template action with a document object containing a misspelled or extra key such as \"tile\", \"templat\", \"docs\", or a metadata key not in the whitelist. Raised from parseTemplateDocTreeDefinition during template rendering with render mode editorInsert.","commonSituations":"Typos in template .md files when writing a createDocTree call; copying an older template snippet that used a field name from a different API; hand-editing a template and adding notes as extra keys.","solutions":["Rename or remove the unknown field so the document object contains only title, template, define, and children.","Check spelling of the intended key (e.g. template not templat, title not tile).","Move auxiliary data out of the createDocTree document object into comments or surrounding template text.","If a legitimately needed field is rejected, upgrade SiYuan so the field is supported by the parser."],"exampleFix":"// before\n{\"title\": \"Doc\", \"templat\": \"tpl.md\"}\n// after\n{\"title\": \"Doc\", \"template\": \"tpl.md\"}","handlingStrategy":"validation","validationCode":"const allowed = [\"title\", \"template\", \"define\", \"children\"];\nfunction validateFields(doc) {\n  return Object.keys(doc).every(k => allowed.includes(k));\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only ever write the four whitelisted keys in createDocTree document objects.","Lint templates for stray keys after hand edits.","Copy from a known-good template example rather than writing from memory."],"tags":["template","validation","schema"],"backgroundTag":"schema-validation-failed","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}