slimtoolkit/slim · error

bad output tar - %s

Error message

bad output tar - %s

What it means

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.

Source

Thrown at pkg/app/master/command/merge/handler.go:274

			//	info.Replaced = append(other.Replaced, other)
			//	index[p] = info
			//	continue
			//}

			other.Dups++
			continue
		}

		info.Replaced = append(other.Replaced, other)
		index[p] = info
	}

	outTarFileName, err := tarFromMap(logger, "", index)

	if !fsutil.Exists(outTarFileName) ||
		!fsutil.IsRegularFile(outTarFileName) ||
		!fsutil.IsTarFile(outTarFileName) {
		xc.FailOn(fmt.Errorf("bad output tar - %s", outTarFileName))
	}

	xc.Out.State("image.data.merge.done")
	xc.Out.State("output.image.generate.start")

	ibo, err := imagebuilder.SimpleBuildOptionsFromImageConfig(outImageConfig)
	xc.FailOn(err)

	ibo.Tags = outputTags

	layerInfo := imagebuilder.LayerDataInfo{
		Type:   imagebuilder.TarSource,
		Source: outTarFileName,
		Params: &imagebuilder.DataParams{
			TargetPath: "/",
		},
	}

View on GitHub (pinned to 81940d17fa)

Solutions

  1. Check free disk space and write permissions in the output directory, then re-run the merge.
  2. Re-pull both source images to rule out corrupted/partial layer data (`docker pull image1 && docker pull image2`).
  3. Run with --debug/verbose logging to see the error returned by tarFromMap that is being discarded before the validation.
  4. Report a bug: the handler ignores tarFromMap's error (`err :=` discarded), so validation failures mask the root cause.

Example fix

// before
outTarFileName, err := tarFromMap(logger, "", index)
if !fsutil.Exists(outTarFileName) || ... {
    xc.FailOn(fmt.Errorf("bad output tar - %s", outTarFileName))
}
// after
outTarFileName, err := tarFromMap(logger, "", index)
if err != nil {
    xc.FailOn(fmt.Errorf("failed to build output tar: %w", err))
}
if !fsutil.Exists(outTarFileName) || ... {
    xc.FailOn(fmt.Errorf("bad output tar - %s", outTarFileName))
}
Defensive patterns

Strategy: fallback

Validate before calling

df -h . | awk 'NR==2 {exit ($5+0 > 90 ? 1 : 0)}' || { echo "disk nearly full"; exit 1; }
[ -w . ] || { echo "output dir not writable"; exit 1; }

Try / catch

if err := runMerge(args); err != nil && strings.Contains(err.Error(), "bad output tar") {
    // free disk space / re-pull images, then retry once
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of slimtoolkit/slim@81940d17fa (2026-08-31). Data as JSON: /api/errors/0b4a4e5a80a667cc. Report an issue: GitHub.