twpayne/chezmoi · error

%s: unsupported typeflag '%c'

Error message

%s: unsupported typeflag '%c'

What it means

walkArchiveTar (internal/chezmoi/archive.go:273) iterates tar headers and handles regular files, directories, symlinks/hardlinks, and GNU/PAX global headers. Any other tar typeflag (e.g. char/block devices, fifos, unknown types) triggers this error naming the entry and typeflag character.

Source

Thrown at internal/chezmoi/archive.go:273

					case errors.Is(err, fs.SkipAll):
						return nil
					case err != nil:
						return err
					}
				}
			}
			switch err := processHeader(relPath, header); {
			case errors.Is(err, fs.SkipDir):
				continue HEADER
			case errors.Is(err, fs.SkipAll):
				return nil
			case err != nil:
				return err
			}
		case tar.TypeXGlobalHeader:
			// Do nothing.
		default:
			return fmt.Errorf("%s: unsupported typeflag '%c'", header.Name, header.Typeflag)
		}
	}
}

// walkArchiveZip walks over all the entries in a zip archive.
func walkArchiveZip(r io.ReaderAt, size int64, f WalkArchiveFunc) error {
	zipReader, err := zip.NewReader(r, size)
	if err != nil {
		return err
	}

	// Process a single header, which might be an implicit parent directory.
	// Remember already-seen directories so we do not visit them twice.
	seenDirErrors := make(map[RelPath]error)
	processHeader := func(relPath RelPath, fileInfo fs.FileInfo) error {
		if fileInfo.IsDir() {
			if seenDirError, ok := seenDirErrors[relPath]; ok {
				return seenDirError

View on GitHub (pinned to f901167e46)

Solutions

  1. Recreate the archive without special entries: exclude /dev and fifo entries.
  2. Convert special entries: replace devices/fifos with regular files or drop them via tar --exclude.
  3. Prefer a modern tar format: `tar --format=gnu` or `--format=pax` when creating the archive.

Example fix

# before
tar -cf site.tar /dev/mydevice
# after
tar --exclude='/dev/*' --format=pax -cf site.tar myfiles/
Defensive patterns

Strategy: validation

Validate before calling

// Pre-scan tar for unsupported typeflags
tr := tar.NewReader(r)
for {
    h, err := tr.Next()
    if err == io.EOF { break }
    if err != nil { return err }
    switch h.Typeflag {
    case tar.TypeReg, tar.TypeDir, tar.TypeSymlink, tar.TypeLink, tar.TypeXGlobalHeader:
    default:
        return fmt.Errorf("unsupported entry %s typeflag %c", h.Name, h.Typeflag)
    }
}

Try / catch

if err := walkArchiveTar(r, fn); err != nil {
    if strings.Contains(err.Error(), "unsupported typeflag") {
        // rebuild archive without special entries
    }
    return err
}

Prevention

When it happens

Trigger: Calling WalkArchive on a tar containing entries with unsupported typeflags such as TypeChar, TypeBlock, TypeFifo, or a typeflag the Go tar package cannot classify.

Common situations: Archives created with `tar --format=v7` or containing device nodes/fifos (e.g. dumped from /dev); archives produced by unusual tar implementations with nonstandard entry types.

Related errors


AI-assisted analysis of twpayne/chezmoi@f901167e46 (2026-09-01). Data as JSON: /api/errors/c0affafc29db04f8. Report an issue: GitHub.