siyuan-note/siyuan · error
Conf.Language(341)
Error message
Conf.Language(341)
What it means
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.
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
Example fix
// before
err = model.Doc2Heading(srcDocID, targetHeadingID)
// after
if model.IsBoxDoc(srcBoxID, srcDocID) {
return errors.New("cannot convert a notebook root document to headings")
}
err = model.Doc2Heading(srcDocID, targetHeadingID) Defensive patterns
Strategy: validation
Validate before calling
if model.IsBoxDoc(boxID, srcDocID) {
return errors.New("cannot convert a notebook root document to headings")
}
err := model.Doc2Heading(srcDocID, targetHeadingID) Try / catch
if err := model.Doc2Heading(srcID, targetID); err != nil {
// Conf.Language(341): source is a notebook root
return fmt.Errorf("Doc2Heading failed: %w", err)
} Prevention
- 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
When it happens
Trigger: 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).
Common situations: 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.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- block [ ] is not a document
- block [ ] is not a document that can declare a child…
- cannot swap a heading with a block in its section
- Conf.Language(20)
- Conf.Language(391)
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/7fb883d73ca2d628.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/heading.go:188
}()
}
return
}
func Doc2Heading(srcID, targetID string, after bool) (srcTreeBox, srcTreePath string, err error) {
if !ast.IsNodeIDPattern(srcID) || !ast.IsNodeIDPattern(targetID) {
return
}
FlushTxQueue()
srcTree, _ := LoadTreeByBlockID(srcID)
if nil == srcTree {
err = ErrBlockNotFound
return
}
if IsBoxDoc(srcTree.Box, srcTree.ID) {
err = errors.New(Conf.Language(341))
return
}
subDir := filepath.Join(util.DataDir, srcTree.Box, strings.TrimSuffix(srcTree.Path, ".sy"))
if gulu.File.IsDir(subDir) {
if !util.IsEmptyDir(subDir) {
err = errors.New(Conf.Language(20))
return
}
if removeErr := os.Remove(subDir); nil != removeErr { // 移除空文件夹不会有副作用
logging.LogWarnf("remove empty dir [%s] failed: %s", subDir, removeErr)
}
}
if nil == treenode.GetBlockTree(targetID) {
// 目标块不存在时忽略处理
returnView on GitHub (pinned to 9f775e8a12)