{"record":{"id":"b16ad7842be37377","repo":"siyuan-note/siyuan","slug":"0","errorCode":"0","errorMessage":"Conf.Language(0)","messagePattern":"Conf\\.Language\\(0\\)","errorType":"validation","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/afa823b6b4e4f183511e0bc0a3be93caa94c7c97/kernel/model/mount.go#L98-L134","documentation":"Returned by model.RenameBox when Conf.Box(boxID) returns nil, i.e. no notebook configuration exists for the given boxID. The localized message is Conf.Language(0): \"Query notebook failed\" — a generic 'notebook not found' error used across the kernel when a box lookup fails.","triggerScenarios":"POST /api/notebook/renameNotebook with a notebook ID that is not mounted/present in the current workspace: a typo'd ID, an ID from another workspace, or a notebook already deleted. The lookup happens before any name validation, so even valid new names fail.","commonSituations":"Stale notebook IDs cached by plugins or external tools after the user deleted/recreated the notebook; renaming a closed or unmounted notebook whose conf is not loaded; scripts operating against the wrong workspace.","solutions":["Fetch the current notebook list via GET /api/notebook/lsNotebooks and use a fresh, existing ID","Confirm you are talking to the correct workspace/kernel instance (port, --workspace flag)","If the notebook was deleted, recreate it (createNotebook) instead of renaming the old ID"],"exampleFix":"// before\nerr := model.RenameBox(boxID, newName) // boxID no longer exists\n\n// after\nnotebooks, _ := ListNotebooks()\nfor _, nb := range notebooks {\n    if nb.ID == boxID {\n        return model.RenameBox(boxID, newName)\n    }\n}\nreturn errors.New(\"notebook not found: \" + boxID)","handlingStrategy":"validation","validationCode":"notebooks, err := model.ListNotebooks()\nif err != nil {\n    return err\n}\nfound := false\nfor _, nb := range notebooks {\n    if nb.ID == boxID {\n        found = true\n        break\n    }\n}\nif !found {\n    return fmt.Errorf(\"notebook %s does not exist\", boxID)\n}\nreturn model.RenameBox(boxID, newName)","typeGuard":null,"tryCatchPattern":"if err := model.RenameBox(boxID, newName); err != nil {\n    if err.Error() == Conf.Language(0) {\n        // notebook missing: refresh IDs and inform user instead of retrying blindly\n    }\n}","preventionTips":["Always resolve notebook IDs from lsNotebooks at call time instead of caching them","Handle workspace switches by invalidating stored notebook IDs","Treat 'Query notebook failed' as a permanent condition — do not retry"],"tags":["notebook","not-found","rename","siyuan"],"backgroundTag":"resource-not-found","analyzedSha":"afa823b6b4e4f183511e0bc0a3be93caa94c7c97","analyzedAt":"2026-08-18T17:04:10.865Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}