{"record":{"id":"0631b180ac7251fa","repo":"weaviate/weaviate","slug":"create-w","errorCode":null,"errorMessage":"create: %w","messagePattern":"create: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"usecases/backup/zip.go","lineNumber":669,"sourceCode":"\t\tf, err := os.OpenFile(target, os.O_CREATE|os.O_WRONLY, os.FileMode(h.Mode))\n\t\tif err != nil {\n\t\t\treturn 0, fmt.Errorf(\"open: %w\", err)\n\t\t}\n\t\tdefer f.Close()\n\n\t\t// Use pwrite semantics (WriteAt) instead of seek+write so that\n\t\t// concurrent goroutines can safely write different parts of the\n\t\t// same file without racing on the shared file-descriptor offset.\n\t\tn, err := io.CopyN(&offsetWriter{f: f, offset: startOffset}, r, h.Size)\n\t\tif err != nil {\n\t\t\treturn n, fmt.Errorf(\"copy split: %w\", err)\n\t\t}\n\t\treturn n, nil\n\t} else {\n\t\t// O_TRUNC is not needed: restores always write into empty directories.\n\t\tf, err := os.OpenFile(target, os.O_CREATE|os.O_WRONLY, os.FileMode(h.Mode))\n\t\tif err != nil {\n\t\t\treturn written, fmt.Errorf(\"create: %w\", err)\n\t\t}\n\t\tdefer f.Close()\n\t\twritten, err = io.Copy(f, r)\n\t\tif err != nil {\n\t\t\treturn written, fmt.Errorf(\"copy: %w\", err)\n\t\t}\n\t\treturn written, nil\n\t}\n}\n\ntype vFileInfo struct {\n\tname    string\n\tsize    int\n\tmodTime time.Time // TODO: get it when parsing source files\n}\n\nfunc (v vFileInfo) Name() string       { return v.name }\nfunc (v vFileInfo) Size() int64        { return int64(v.size) }","sourceCodeStart":651,"sourceCodeEnd":687,"githubUrl":"https://github.com/weaviate/weaviate/blob/75aa4b6d11f8818305aafd4440b4e32794f7ca04/usecases/backup/zip.go#L651-L687","documentation":"For a regular (non-split) file in the restore archive, copyFile creates the destination with os.OpenFile(O_CREATE|O_WRONLY, header mode). This error wraps the OS open failure for that file. Note O_TRUNC is intentionally not set because restores always write into empty directories.","triggerScenarios":"os.OpenFile fails while extracting a regular tar entry: destination directory missing or removed, insufficient permissions on destPath, file exists with mode bits that forbid writing, read-only filesystem, or disk full preventing creation.","commonSituations":"Restore target volume read-only or out of space; Weaviate runs as unprivileged user lacking write access to the restore path; leftover files from an aborted previous restore with restrictive modes; SELinux/AppArmor blocking writes to the destination.","solutions":["Ensure the restore destination directory exists and is writable by the Weaviate process user.","Clear any leftovers from a failed prior restore and restore into a clean empty directory.","Check disk space/inodes and that the filesystem is not mounted read-only (df -h, mount).","Read the wrapped OS error in the message to identify the precise cause (permission denied, no space left, etc.).","If using containerized Weaviate, verify the volume mount permissions map to the container's user."],"exampleFix":"// before: destination owned by root, weaviate runs as user 1000\n# docker run -v /root/backups:/backups weaviate\n// after: chown the destination to the weaviate user\n# chown -R 1000:1000 /var/lib/weaviate/backups\n# docker run -v /var/lib/weaviate/backups:/backups weaviate","handlingStrategy":"validation","validationCode":"if st, err := os.Stat(destPath); err != nil || !st.IsDir() {\n    return fmt.Errorf(\"destination %s must exist as a directory\", destPath)\n}\nprobe := filepath.Join(destPath, \".write-probe\")\nif err := os.WriteFile(probe, nil, 0o644); err != nil {\n    return fmt.Errorf(\"destination not writable: %w\", err)\n}\nos.Remove(probe)","typeGuard":null,"tryCatchPattern":"err := doRestore(ctx)\nvar perr *fs.PathError\nif errors.As(err, &perr) && errors.Is(perr.Err, os.ErrPermission) {\n    // chown/chmod destination and retry\n}","preventionTips":["Chown the restore destination to the user Weaviate runs as before starting.","Restore into empty directories only — clean up aborted restores first.","Check that volume mounts in containers map permissions correctly to the container user.","Confirm the filesystem is not mounted read-only (mount | grep ro)."],"tags":["filesystem","backup","restore","file-create"],"backgroundTag":"file-open-failed","analyzedSha":"75aa4b6d11f8818305aafd4440b4e32794f7ca04","analyzedAt":"2026-09-04T14:58:20.392Z","contentChangedAt":"2026-09-04T14:58:20.392Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}