{"record":{"id":"b16ad7842be37377","repo":"siyuan-note/siyuan","slug":"0-b16ad7","errorCode":"0","errorMessage":"Query notebook failed","messagePattern":"Query notebook failed","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/mount.go","lineNumber":116,"sourceCode":"\tif initializeBoxDoc {\n\t\tif _, err = ensureBoxDoc0(id); err != nil {\n\t\t\ttreenode.RemoveBlockTreesByBoxID(id)\n\t\t\tsql.DeleteBoxQueue(id)\n\t\t\tif removeErr := filelock.Remove(boxLocalPath); nil != removeErr {\n\t\t\t\tlogging.LogErrorf(\"remove box [%s] after initializing box document failed: %s\", id, removeErr)\n\t\t\t}\n\t\t\treturn \"\", err\n\t\t}\n\t}\n\tIncSync()\n\tlogging.LogInfof(\"created box [%s]\", id)\n\treturn\n}\n\nfunc RenameBox(boxID, name string) (err error) {\n\tbox := Conf.Box(boxID)\n\tif nil == box {\n\t\treturn errors.New(Conf.Language(0))\n\t}\n\n\tname = normalizeBoxName(name)\n\tif 512 < utf8.RuneCountInString(name) {\n\t\t// 限制笔记本名和文档名最大长度为 `512` https://github.com/siyuan-note/siyuan/issues/6299\n\t\terr = errors.New(Conf.Language(106))\n\t\treturn\n\t}\n\n\tboxConf := box.GetConf()\n\tboxConf.Name = name\n\tbox.Name = name\n\tif err = box.SaveConf(boxConf); err != nil {\n\t\tlogging.LogErrorf(\"save box conf [%s] failed: %s\", boxID, err)\n\t\treturn\n\t}\n\tif err = renameBoxDoc(boxID, name); err != nil {\n\t\tlogging.LogErrorf(\"rename box document [box=%s] failed: %s\", boxID, err)","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/model/mount.go#L98-L134","documentation":"In RenameBox, Conf.Box(boxID) returned nil (no mounted notebook with that ID), so the function returns errors.New(Conf.Language(0)) = 'Query notebook failed'. This is the not-found / not-mounted guard that precedes the rename logic; it fires before the name-length check (796).","triggerScenarios":"Calling RenameBox with a boxID that does not correspond to any currently mounted notebook: the notebook was removed, was never created, belongs to an unmounted encrypted notebook, or the ID is malformed but happened to escape earlier validation.","commonSituations":"Stale UI state referencing a deleted notebook; race between remove and rename; encrypted notebook not yet unlocked/mounted; typo or copy-paste of a wrong ID; calling rename on the user-guide notebook which may be special-cased.","solutions":["Refresh the notebook list (ListNotebooks) and use a current, valid boxID before calling RenameBox.","If the target is an encrypted notebook, ensure it is unlocked/mounted first (isEncryptedBoxMounted).","Avoid calling RenameBox concurrently with RemoveBox on the same ID; serialise such operations.","Validate the ID with ast.IsNodeIDPattern and confirm presence in Conf before invoking."],"exampleFix":"// before\nerr := model.RenameBox(staleBoxID, name) // Language(0)\n\n// after\nif Conf.Box(boxID) == nil {\n    return fmt.Errorf(\"notebook %s not found/mounted\", boxID)\n}\nerr := model.RenameBox(boxID, name)","handlingStrategy":"validation","validationCode":"func notebookExists(boxID string) bool {\n    if !ast.IsNodeIDPattern(boxID) { return false }\n    return Conf.Box(boxID) != nil\n}","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Refresh ListNotebooks before acting on a stale UI reference.","Ensure encrypted notebooks are unlocked/mounted before rename.","Serialise rename vs remove on the same ID."],"tags":["notebook","mount","rename","not-found","validation"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}