{"record":{"id":"0b4a4e5a80a667cc","repo":"slimtoolkit/slim","slug":"bad-output-tar-s","errorCode":null,"errorMessage":"bad output tar - %s","messagePattern":"bad output tar - (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/app/master/command/merge/handler.go","lineNumber":274,"sourceCode":"\t\t\t//\tinfo.Replaced = append(other.Replaced, other)\n\t\t\t//\tindex[p] = info\n\t\t\t//\tcontinue\n\t\t\t//}\n\n\t\t\tother.Dups++\n\t\t\tcontinue\n\t\t}\n\n\t\tinfo.Replaced = append(other.Replaced, other)\n\t\tindex[p] = info\n\t}\n\n\toutTarFileName, err := tarFromMap(logger, \"\", index)\n\n\tif !fsutil.Exists(outTarFileName) ||\n\t\t!fsutil.IsRegularFile(outTarFileName) ||\n\t\t!fsutil.IsTarFile(outTarFileName) {\n\t\txc.FailOn(fmt.Errorf(\"bad output tar - %s\", outTarFileName))\n\t}\n\n\txc.Out.State(\"image.data.merge.done\")\n\txc.Out.State(\"output.image.generate.start\")\n\n\tibo, err := imagebuilder.SimpleBuildOptionsFromImageConfig(outImageConfig)\n\txc.FailOn(err)\n\n\tibo.Tags = outputTags\n\n\tlayerInfo := imagebuilder.LayerDataInfo{\n\t\tType:   imagebuilder.TarSource,\n\t\tSource: outTarFileName,\n\t\tParams: &imagebuilder.DataParams{\n\t\t\tTargetPath: \"/\",\n\t\t},\n\t}\n","sourceCodeStart":256,"sourceCodeEnd":292,"githubUrl":"https://github.com/slimtoolkit/slim/blob/81940d17fa112cc678e32209214bcb2355cb3004/pkg/app/master/command/merge/handler.go#L256-L292","documentation":"After merging the layer maps, OnCommand writes the merged data to a tar file via tarFromMap and then validates the output: the file must exist, be a regular file, and be a readable tar archive. If any check fails, the command aborts with 'bad output tar'. The merge produced an unusable output artifact.","triggerScenarios":"tarFromMap returns an empty/unset filename (error swallowed — err is not checked) or writes a corrupt/missing file, so fsutil.Exists/IsRegularFile/IsTarFile fails in merge/handler.go:274.","commonSituations":"Disk full or permission denied in the output directory so the tar write failed silently; source image layers corrupted or partially pulled; filesystem not supporting the temp file; tarFromMap failing internally but its error ignored by the caller.","solutions":["Check free disk space and write permissions in the output directory, then re-run the merge.","Re-pull both source images to rule out corrupted/partial layer data (`docker pull image1 && docker pull image2`).","Run with --debug/verbose logging to see the error returned by tarFromMap that is being discarded before the validation.","Report a bug: the handler ignores tarFromMap's error (`err :=` discarded), so validation failures mask the root cause."],"exampleFix":"// before\noutTarFileName, err := tarFromMap(logger, \"\", index)\nif !fsutil.Exists(outTarFileName) || ... {\n    xc.FailOn(fmt.Errorf(\"bad output tar - %s\", outTarFileName))\n}\n// after\noutTarFileName, err := tarFromMap(logger, \"\", index)\nif err != nil {\n    xc.FailOn(fmt.Errorf(\"failed to build output tar: %w\", err))\n}\nif !fsutil.Exists(outTarFileName) || ... {\n    xc.FailOn(fmt.Errorf(\"bad output tar - %s\", outTarFileName))\n}","handlingStrategy":"fallback","validationCode":"df -h . | awk 'NR==2 {exit ($5+0 > 90 ? 1 : 0)}' || { echo \"disk nearly full\"; exit 1; }\n[ -w . ] || { echo \"output dir not writable\"; exit 1; }","typeGuard":null,"tryCatchPattern":"if err := runMerge(args); err != nil && strings.Contains(err.Error(), \"bad output tar\") {\n    // free disk space / re-pull images, then retry once\n}","preventionTips":["Ensure ample free disk space before large image merges","Re-pull source images to avoid corrupt layers","Run merges in a writable working directory","Enable verbose logging to surface errors tarFromMap swallows"],"tags":["tar","image-merge","filesystem"],"backgroundTag":"corrupt-archive-output","analyzedSha":"81940d17fa112cc678e32209214bcb2355cb3004","analyzedAt":"2026-08-31T23:06:12.682Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}