{"record":{"id":"b5646d5c12cfacb5","repo":"hashicorp/packer","slug":"unable-to-get-fileinfo-for-s-s","errorCode":null,"errorMessage":"Unable to get fileinfo for %s: %s","messagePattern":"Unable to get fileinfo for (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"post-processor/compress/post-processor.go","lineNumber":390,"sourceCode":"\t}\n\t_ = gzipWriter.SetConcurrency(500000, runtime.GOMAXPROCS(-1))\n\treturn gzipWriter, nil\n}\n\nfunc createTarArchive(files []string, output io.WriteCloser) error {\n\tarchive := tar.NewWriter(output)\n\tdefer archive.Close()\n\n\tfor _, path := range files {\n\t\tfile, err := os.Open(path)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"Unable to read file %s: %s\", path, err)\n\t\t}\n\t\tdefer file.Close()\n\n\t\tfi, err := file.Stat()\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"Unable to get fileinfo for %s: %s\", path, err)\n\t\t}\n\n\t\theader, err := tar.FileInfoHeader(fi, path)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"Failed to create tar header for %s: %s\", path, err)\n\t\t}\n\n\t\t// workaround for archive format on go >=1.10\n\t\tsetHeaderFormat(header)\n\n\t\tif err := archive.WriteHeader(header); err != nil {\n\t\t\treturn fmt.Errorf(\"Failed to write tar header for %s: %s\", path, err)\n\t\t}\n\n\t\tif _, err := io.Copy(archive, file); err != nil {\n\t\t\treturn fmt.Errorf(\"Failed to copy %s data to archive: %s\", path, err)\n\t\t}\n\t}","sourceCodeStart":372,"sourceCodeEnd":408,"githubUrl":"https://github.com/hashicorp/packer/blob/eb36e3c3e48a036f3e8cc94087636ee72e1303c9/post-processor/compress/post-processor.go#L372-L408","documentation":"createTarArchive opened an artifact file but file.Stat() failed, so tar header creation cannot proceed. The post-processor needs the file's size/mode/timestamps to build a tar header; without stat metadata it aborts and PostProcess reports 'Error creating tar'.","triggerScenarios":"createTarArchive calls file.Stat() on a successfully opened file and the OS returns an error — rare, usually indicating the file was deleted between Open and Stat, or an underlying filesystem I/O error.","commonSituations":"Files on flaky network mounts (NFS/SMB) whose metadata lookups fail; concurrent cleanup jobs removing artifacts during packaging; exotic filesystems with unreliable stat support.","solutions":["Re-run the build; this is frequently a race with file deletion","Check the filesystem backing the artifact (dmesg / mount health) for I/O errors","Avoid external cleanup processes touching the output directory during the build","Use a local output directory instead of a network mount"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// pre-flight: confirm stat works on all artifact files (detects flaky mounts)\nfor _, p := range artifact.Files() {\n    if _, err := os.Stat(p); err != nil {\n        return fmt.Errorf(\"stat unavailable for %s: %w\", p, err)\n    }\n}","typeGuard":null,"tryCatchPattern":"// Go: stat races are transient; retry the post-process once\nartifact, _, _, err := pp.PostProcess(ctx, ui, artifact)\nif err != nil && strings.Contains(err.Error(), \"Unable to get fileinfo\") {\n    time.Sleep(time.Second)\n    return pp.PostProcess(ctx, ui, artifact)\n}","preventionTips":["Prefer local filesystems over NFS/SMB for build outputs","Stop external cleanup jobs that touch output directories during builds","Check filesystem health (dmesg) if stat errors recur","Re-run the pipeline when errors are sporadic"],"tags":["packer","post-processor","tar","filesystem"],"backgroundTag":"stat-fileinfo-failed","analyzedSha":"eb36e3c3e48a036f3e8cc94087636ee72e1303c9","analyzedAt":"2026-09-05T13:20:43.127Z","contentChangedAt":"2026-09-05T13:20:43.127Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}