{"record":{"id":"2aeb926d410fd754","repo":"siyuan-note/siyuan","slug":"can-not-get-or-create-rollback-box","errorCode":null,"errorMessage":"can not get or create rollback box","messagePattern":"can not get or create rollback box","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/history.go","lineNumber":1464,"sourceCode":"\tif nil == ret {\n\t\tboxName := \"Rollback\"\n\t\tret = GetBoxByName(boxName)\n\t\tif nil == ret {\n\t\t\tvar id string\n\t\t\tid, err = CreateBox(boxName)\n\t\t\tif nil != err {\n\t\t\t\treturn\n\t\t\t}\n\t\t\t_, err = Mount(id)\n\t\t\tif nil != err {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tret = Conf.Box(id)\n\t\t\tcreated = true\n\t\t}\n\t}\n\tif nil == ret {\n\t\terr = errors.New(\"can not get or create rollback box\")\n\t\treturn\n\t}\n\treturn\n}\n","sourceCodeStart":1446,"sourceCodeEnd":1469,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/history.go#L1446-L1469","documentation":"getRollbackBox resolves (or lazily creates) the special history box used to stage rollback operations. If, after looking up the configured box ID and attempting creation, no *conf.Box can be produced, this sentinel error is returned. It means the rollback cannot proceed because the target box object is unavailable.","triggerScenarios":"RollbackDocHistory or RollbackRepoSnapshotFile calls getRollbackBox; the history-box ID is not a known box, the creation path fails or produces a box object that is still nil (e.g. invalid ID format, workspace data dir not writable so the box directory could not be created/registered).","commonSituations":"Workspace data directory permissions dropped; the internal history box was manually deleted or renamed on disk while the kernel is running; corrupt or hand-edited configuration pointing the rollback box at an invalid ID; a previously failed creation left inconsistent state.","solutions":["Restart the kernel so box registration is rebuilt from the data directory.","Ensure the workspace data directory exists and is writable by the kernel process.","Check kernel logs just before this error for the box-creation failure cause and fix it.","Do not manually delete/rename the internal history box directories under data/history or data/<box> while SiYuan runs.","Retry the rollback after the box is restored; if data was damaged, restore the workspace from backup/sync snapshot."],"exampleFix":"// guard the caller before performing rollback\nbox, err := getRollbackBox()\nif err != nil {\n    return fmt.Errorf(\"rollback aborted, history box unavailable: %w\", err)\n}","handlingStrategy":"try-catch","validationCode":"// before rollback, verify the history box exists\nif Conf.Box(historyBoxID) == nil {\n    return fmt.Errorf(\"rollback box %s not available; restart kernel to re-register boxes\", historyBoxID)\n}","typeGuard":null,"tryCatchPattern":"box, err := getRollbackBox()\nif err != nil {\n    logging.LogErrorf(\"rollback unavailable: %v\", err)\n    return err\n}","preventionTips":["Do not manually delete or rename internal box directories while the kernel runs","Restart the kernel after any manual workspace manipulation","Keep the data directory writable by the kernel process"],"tags":["history","rollback","internal-state","workspace"],"backgroundTag":"resource-not-found","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"}