{"record":{"id":"fc5103da5c50f084","repo":"siyuan-note/siyuan","slug":"query-notebook-failed-fc5103","errorCode":null,"errorMessage":"Query notebook failed","messagePattern":"Query notebook failed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/file.go","lineNumber":404,"sourceCode":"\tret = []*File{}\n\tif flashcard && IsEncryptedBox(boxID) {\n\t\treturn nil, 0, errors.New(Conf.Language(313))\n\t}\n\n\tvar deck *riff.Deck\n\tvar deckBlockIDs []string\n\tif flashcard {\n\t\tdeck = Decks[builtinDeckID]\n\t\tif nil == deck {\n\t\t\treturn\n\t\t}\n\n\t\tdeckBlockIDs = deck.GetBlockIDs()\n\t}\n\n\tbox := Conf.Box(boxID)\n\tif nil == box {\n\t\treturn nil, 0, errors.New(Conf.Language(0))\n\t}\n\n\tboxConf := box.GetConf()\n\n\tif util.SortModeUnassigned == sortMode {\n\t\tsortMode = Conf.FileTree.Sort\n\t\tif util.SortModeFileTree != boxConf.SortMode {\n\t\t\tsortMode = boxConf.SortMode\n\t\t}\n\t}\n\n\tvar files []*FileInfo\n\tstart := time.Now()\n\tfiles, totals, err = box.Ls(listPath)\n\tif err != nil {\n\t\treturn\n\t}\n\telapsed := time.Since(start).Milliseconds()","sourceCodeStart":386,"sourceCodeEnd":422,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/model/file.go#L386-L422","documentation":"Thrown by ListDocTree when Conf.Box(boxID) returns nil, meaning no notebook with the given boxID is registered in the current configuration. Conf.Language(0) = 'Query notebook failed'. This is a pure lookup failure — the ID does not match any loaded notebook, the notebook was deleted, or it has not been opened/initialized yet.","triggerScenarios":"Calling ListDocTree with a boxID that does not exist in Conf.GetOpenedBoxes() or Conf.GetBoxes(). Common when the ID is stale (notebook was removed), mistyped, or belongs to a notebook that exists on disk but hasn't been loaded into Conf state.","commonSituations":"A frontend tab or plugin holds a stale notebook ID after the user deleted or closed the notebook. A sync conflict removed a notebook but the UI wasn't refreshed. The workspace was switched but cached IDs persisted.","solutions":["Verify the boxID exists by calling Conf.Box(boxID) or listing available notebooks before invoking ListDocTree.","If the notebook was recently created or imported, ensure the kernel has finished loading it — call the notebook refresh/reload API first.","Refresh the client-side notebook list to discard stale IDs after workspace switches or notebook deletion.","Check kernel logs for notebook load failures at startup that may explain why the box isn't registered."],"exampleFix":"// before\nfiles, totals, err := model.ListDocTree(boxID, path, sort, flashcard, show, max)\n\n// after\nif nil == conf.Box(boxID) {\n    return nil, 0, fmt.Errorf(\"notebook %s is not available\", boxID)\n}\nfiles, totals, err := model.ListDocTree(boxID, path, sort, flashcard, show, max)","handlingStrategy":"validation","validationCode":"// Pre-check: validate boxID exists before listing\nif conf.Box(boxID) == nil {\n    return nil, 0, fmt.Errorf(\"notebook %s does not exist\", boxID)\n}","typeGuard":"func notebookExists(boxID string) bool {\n    return conf.Box(boxID) != nil\n}","tryCatchPattern":null,"preventionTips":["Always validate boxID via conf.Box(boxID) before calling ListDocTree.","Refresh the notebook list in the UI after workspace switches or notebook deletion.","For API clients, re-fetch notebooks at session start and cache only for the session."],"tags":["notebook","validation","stale-reference"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}