{"record":{"id":"7fb883d73ca2d628","repo":"siyuan-note/siyuan","slug":"conf-language-341","errorCode":null,"errorMessage":"Conf.Language(341)","messagePattern":"Conf\\.Language\\(341\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/heading.go","lineNumber":188,"sourceCode":"\t\t}()\n\t}\n\treturn\n}\n\nfunc Doc2Heading(srcID, targetID string, after bool) (srcTreeBox, srcTreePath string, err error) {\n\tif !ast.IsNodeIDPattern(srcID) || !ast.IsNodeIDPattern(targetID) {\n\t\treturn\n\t}\n\n\tFlushTxQueue()\n\n\tsrcTree, _ := LoadTreeByBlockID(srcID)\n\tif nil == srcTree {\n\t\terr = ErrBlockNotFound\n\t\treturn\n\t}\n\tif IsBoxDoc(srcTree.Box, srcTree.ID) {\n\t\terr = errors.New(Conf.Language(341))\n\t\treturn\n\t}\n\n\tsubDir := filepath.Join(util.DataDir, srcTree.Box, strings.TrimSuffix(srcTree.Path, \".sy\"))\n\tif gulu.File.IsDir(subDir) {\n\t\tif !util.IsEmptyDir(subDir) {\n\t\t\terr = errors.New(Conf.Language(20))\n\t\t\treturn\n\t\t}\n\n\t\tif removeErr := os.Remove(subDir); nil != removeErr { // 移除空文件夹不会有副作用\n\t\t\tlogging.LogWarnf(\"remove empty dir [%s] failed: %s\", subDir, removeErr)\n\t\t}\n\t}\n\n\tif nil == treenode.GetBlockTree(targetID) {\n\t\t// 目标块不存在时忽略处理\n\t\treturn","sourceCodeStart":170,"sourceCodeEnd":206,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/heading.go#L170-L206","documentation":"Doc2Heading converts a whole document into heading content under a target heading. If the source document is itself the root document of its notebook (IsBoxDoc), the operation would destroy the notebook structure, so it is rejected with Conf.Language(341) — a localized message meaning the document is a notebook root and cannot be converted.","triggerScenarios":"Calling Doc2Heading(srcID, targetID) where srcID resolves to a tree whose ID equals the notebook's root document (the .sy file that IS the notebook's home doc, i.e. IsBoxDoc(srcTree.Box, srcTree.ID) is true).","commonSituations":"Dragging a notebook's root document onto a heading in another notebook; menu automation that doesn't distinguish root docs from child docs; batch refactoring scripts converting many docs to headings.","solutions":["Choose a non-root document in the notebook as the source for Doc2Heading","Check IsBoxDoc(boxID, docID) before calling and skip or warn for root documents","If the intent is to merge the whole notebook, create a regular child document containing the content first and convert that"],"exampleFix":"// before\nerr = model.Doc2Heading(srcDocID, targetHeadingID)\n// after\nif model.IsBoxDoc(srcBoxID, srcDocID) {\n    return errors.New(\"cannot convert a notebook root document to headings\")\n}\nerr = model.Doc2Heading(srcDocID, targetHeadingID)","handlingStrategy":"validation","validationCode":"if model.IsBoxDoc(boxID, srcDocID) {\n    return errors.New(\"cannot convert a notebook root document to headings\")\n}\nerr := model.Doc2Heading(srcDocID, targetHeadingID)","typeGuard":null,"tryCatchPattern":"if err := model.Doc2Heading(srcID, targetID); err != nil {\n    // Conf.Language(341): source is a notebook root\n    return fmt.Errorf(\"Doc2Heading failed: %w\", err)\n}","preventionTips":["Check IsBoxDoc for every candidate source in batch conversions","Disable the convert-to-heading action for notebook root docs in menus","Require an explicit child document when users want to merge notebook-level content"],"tags":["heading","document","protected-operation"],"backgroundTag":"unsupported-operation","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"}