{"record":{"id":"c24a9171cd1a7cf9","repo":"siyuan-note/siyuan","slug":"mkdir-master-password-migration-dir-failed-w","errorCode":null,"errorMessage":"mkdir master password migration dir failed: %w","messagePattern":"mkdir master password migration dir failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/crypto.go","lineNumber":540,"sourceCode":"\tNewWrappedDEK []byte `json:\"newWrappedDEK\"`\n\tNewWrapNonce  []byte `json:\"newWrapNonce\"`\n\tMetadata      []byte `json:\"metadata\"`\n}\n\nfunc masterPasswordMigrationPath() string {\n\treturn filepath.Join(util.DataDir, \".siyuan\", \"master-password-migration.json\")\n}\n\nfunc writeMasterPasswordMigration(m *masterPasswordMigration) error {\n\tmasterPasswordMigrationMu.Lock()\n\tdefer masterPasswordMigrationMu.Unlock()\n\treturn writeMasterPasswordMigrationUnlocked(m)\n}\n\nfunc writeMasterPasswordMigrationUnlocked(m *masterPasswordMigration) error {\n\tp := masterPasswordMigrationPath()\n\tif err := os.MkdirAll(filepath.Dir(p), 0755); err != nil {\n\t\treturn fmt.Errorf(\"mkdir master password migration dir failed: %w\", err)\n\t}\n\tdata, err := gulu.JSON.MarshalIndentJSON(m, \"\", \"  \")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"marshal master password migration failed: %w\", err)\n\t}\n\treturn filelock.WriteFile(p, data)\n}\n\nfunc readMasterPasswordMigration() (*masterPasswordMigration, error) {\n\tmasterPasswordMigrationMu.Lock()\n\tdefer masterPasswordMigrationMu.Unlock()\n\treturn readMasterPasswordMigrationUnlocked()\n}\n\nfunc readMasterPasswordMigrationUnlocked() (*masterPasswordMigration, error) {\n\tp := masterPasswordMigrationPath()\n\tif !filelock.IsExist(p) {\n\t\treturn nil, nil","sourceCodeStart":522,"sourceCodeEnd":558,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/model/crypto.go#L522-L558","documentation":"writeMasterPasswordMigrationUnlocked could not create the directory holding the master password migration state file. The migration record (unlocked box material) cannot be persisted, so the migration step aborts with this wrapped OS error.","triggerScenarios":"writeMasterPasswordMigration or removeMasterPasswordMigrationBox calls writeMasterPasswordMigrationUnlocked; os.MkdirAll(filepath.Dir(masterPasswordMigrationPath()), 0755) fails due to permissions, read-only FS, or a non-directory in the path.","commonSituations":"Workspace data directory with wrong ownership, read-only mount, full disk, or a stray file occupying the migration directory path.","solutions":["Grant the kernel process write permission on the workspace data directory","Remove any regular file occupying the migration directory path","Free disk space or remount read-write","Verify masterPasswordMigrationPath() points inside the active workspace"],"exampleFix":"// before: data dir not writable\nls -ld ~/SiYuan/data # root-owned\n// after\nsudo chown -R $USER ~/SiYuan/data\nerr := writeMasterPasswordMigration(m) // succeeds","handlingStrategy":"try-catch","validationCode":"if err := os.MkdirAll(filepath.Dir(masterPasswordMigrationPath()), 0755); err != nil {\n    return fmt.Errorf(\"migration dir not creatable: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := writeMasterPasswordMigration(m); err != nil {\n    if os.IsPermission(errors.Unwrap(err)) {\n        // instruct user to fix workspace data directory ownership\n    }\n    return err\n}","preventionTips":["Ensure the kernel process owns the workspace data directory","Avoid running multiple SiYuan instances against one workspace","Keep the workspace off read-only mounts and synced/locked folders","Precreate the data directory structure with correct permissions during deployment"],"tags":["go","filesystem","mkdir","migration"],"backgroundTag":"mkdir-permission-denied","analyzedSha":"8641553a1f07374001902d3ce773285db1292b2d","analyzedAt":"2026-09-11T16:08:28.414Z","contentChangedAt":"2026-09-11T16:08:28.414Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}