{"record":{"id":"be01a1ee9476cf24","repo":"weaviate/weaviate","slug":"create-temp-class-folder-s-w","errorCode":null,"errorMessage":"create temp class folder %s: %w","messagePattern":"create temp class folder (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"usecases/backup/backend.go","lineNumber":949,"sourceCode":"\n\tif fw.migrator != nil {\n\t\tif err := fw.migrator(classTempDir); err != nil {\n\t\t\treturn fmt.Errorf(\"migrate from pre 1.23: %w\", err)\n\t\t}\n\t}\n\n\treturn nil\n}\n\n// writeTempFiles writes class files into a temporary directory\n// temporary directory path = d.tempDir/className\n// Function makes sure that created files will be removed in case of an error\nfunc (fw *fileWriter) writeTempFiles(ctx context.Context, classTempDir, overrideBucket, overridePath string, desc *backup.ClassDescriptor, compressionType backup.CompressionType) (err error) {\n\tif err := os.RemoveAll(classTempDir); err != nil {\n\t\treturn fmt.Errorf(\"remove %s: %w\", classTempDir, err)\n\t}\n\tif err := os.MkdirAll(classTempDir, os.ModePerm); err != nil {\n\t\treturn fmt.Errorf(\"create temp class folder %s: %w\", classTempDir, err)\n\t}\n\tctx, cancel := context.WithCancel(ctx)\n\tdefer cancel()\n\n\teg, ctx := enterrors.NewErrorGroupWithContextWrapper(fw.logger, ctx)\n\teg.SetLimit(fw.GoPoolSize)\n\tfor k := range desc.Chunks {\n\t\t// Check for cancellation before processing each chunk\n\t\tif err := ctx.Err(); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tchunk := chunkKey(desc.Name, k)\n\t\teg.Go(func() error {\n\t\t\treturn fw.readAndUnzipChunk(classTempDir, compressionType, chunk,\n\t\t\t\tfunc(w io.WriteCloser) error {\n\t\t\t\t\t_, err := fw.backend.Read(ctx, chunk, overrideBucket, overridePath, w)\n\t\t\t\t\treturn err\n\t\t\t\t})","sourceCodeStart":931,"sourceCodeEnd":967,"githubUrl":"https://github.com/weaviate/weaviate/blob/75aa4b6d11f8818305aafd4440b4e32794f7ca04/usecases/backup/backend.go#L931-L967","documentation":"Wrap from writeTempFiles (usecases/backup/backend.go:949) when os.MkdirAll cannot create the class staging directory <tempDir>/<className> after the old one was removed. Without this directory, backup chunks cannot be unzipped into place, so the restore of the class fails.","triggerScenarios":"Restoring a class when the parent temp directory does not exist or cannot be created: missing parent path, read-only filesystem, ENOSPC is not typical here but EACCES/EEXIST-on-file are, or a file occupies a component of the path.","commonSituations":"Data path directory deleted while Weaviate runs; wrong persistence DATA_PATH configuration pointing at an unwritable location; a regular file named like the temp directory blocks creation; container user lacks write access to the mount.","solutions":["Check the wrapped OS error and verify the parent directories of the configured data path exist and are writable by the Weaviate process user.","Confirm the persistence/data path configuration (PERSISTENCE_DATA_PATH) points to a valid writable volume.","Remove any regular file that occupies the temp directory path component.","If running in Kubernetes/Docker, fix the PVC/mount permissions and restart the node, then retry the restore."],"exampleFix":"// before: PERSISTENCE_DATA_PATH points to unwritable dir\n// WEAVIATE_PERSISTENCE_DATA_PATH=/nonexistent\n// after: mount and point at a writable volume\n// WEAVIATE_PERSISTENCE_DATA_PATH=/var/lib/weaviate","handlingStrategy":"validation","validationCode":"// preflight: parent of the temp dir must exist and be writable\nparent := filepath.Dir(filepath.Join(dataPath, \"backup-temp\", className))\nif fi, err := os.Stat(parent); err != nil || !fi.IsDir() {\n    return fmt.Errorf(\"parent staging dir %s missing or not a directory\", parent)\n}\n// also verify PERSISTENCE_DATA_PATH is writable at startup","typeGuard":"func isMkdirFailure(err error) bool {\n    return strings.Contains(err.Error(), \"create temp class folder\")\n}","tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"create temp class folder\") {\n    // EACCES/ENOENT on parent -> fix PERSISTENCE_DATA_PATH / permissions, retry\n    log.Printf(\"cannot create staging dir: %v\", err)\n}","preventionTips":["Set PERSISTENCE_DATA_PATH to an existing, writable volume at deploy time.","Don't delete or recreate the data directory while Weaviate is running.","Verify volume mounts in Kubernetes (readOnly:false, correct fsGroup).","Ensure no regular file shares a path component with the temp directory name."],"tags":["backup","filesystem","permissions","go"],"backgroundTag":"mkdir-permission-denied","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"}