{"record":{"id":"a7c93ced1f1b23db","repo":"benbjohnson/litestream","slug":"create-parent-directory-w-a7c93c","errorCode":null,"errorMessage":"create parent directory: %w","messagePattern":"create parent directory: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"replica.go","lineNumber":724,"sourceCode":"\t\t\t\tinfo.Level, info.MinTXID, info.MaxTXID, info.Size, ltx.HeaderSize)\n\t\t}\n\n\t\tr.Logger().Debug(\"opening ltx file for restore\", \"level\", info.Level, \"min\", info.MinTXID, \"max\", info.MaxTXID)\n\n\t\trdrs = append(rdrs, internal.NewResumableReader(ctx, r.Client, info.Level, info.MinTXID, info.MaxTXID, info.Size, nil, r.Logger()))\n\t}\n\n\tif len(rdrs) == 0 {\n\t\treturn fmt.Errorf(\"no matching backup files available\")\n\t}\n\n\t// Create parent directory if it doesn't exist.\n\tvar dirInfo os.FileInfo\n\tif db := r.DB(); db != nil {\n\t\tdirInfo = db.dirInfo\n\t}\n\tif err := internal.MkdirAll(filepath.Dir(opt.OutputPath), dirInfo); err != nil {\n\t\treturn fmt.Errorf(\"create parent directory: %w\", err)\n\t}\n\n\t// Output to temp file & atomically rename.\n\ttmpOutputPath := opt.OutputPath + \".tmp\"\n\tr.Logger().Debug(\"compacting into database\", \"path\", tmpOutputPath, \"n\", len(rdrs))\n\tdefer func() { _ = os.Remove(tmpOutputPath) }()\n\n\tf, err := os.Create(tmpOutputPath)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"create temp database path: %w\", err)\n\t}\n\tdefer func() { _ = f.Close() }()\n\n\tpr, pw := io.Pipe()\n\n\tgo func() {\n\t\tc, err := ltx.NewCompactor(pw, rdrs)\n\t\tif err != nil {","sourceCodeStart":706,"sourceCodeEnd":742,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/replica.go#L706-L742","documentation":"Wraps internal.MkdirAll failure in Replica.Restore while creating the parent directory of the restore output path. Fires when the output directory cannot be created (permissions, path conflict), so the restored database file has nowhere to be written.","triggerScenarios":"Thrown at replica.go:724 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the output path for conflicts with existing files","Create the directory manually or fix permissions"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3","analyzedAt":"2026-09-06T18:29:25.564Z","contentChangedAt":"2026-09-06T18:29:25.564Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}