anomalyco/sst · error

invalid archive name format: %s

Error message

invalid archive name format: %s

What it means

After extracting a .tar.gz sdist, the code strips `.tar.gz` and splits the remaining name on the last hyphen to derive `pkgname-version`. If the filename has no hyphen at all, the package directory cannot be inferred and this error is thrown.

Source

Thrown at pkg/runtime/python/build.go:331

			return fmt.Errorf("failed to extract wheel: %w", err)
		}

		os.Remove(archiveFile)

		return nil
	}

	// Extract tar.gz
	if err := extractTarGz(archiveFile, outputDir); err != nil {
		return fmt.Errorf("failed to extract archive: %w", err)
	}

	// Get the directory name without version number
	archiveBaseName := filepath.Base(archiveFile)
	dirName := strings.TrimSuffix(archiveBaseName, ".tar.gz")
	lastHyphen := strings.LastIndex(dirName, "-")
	if lastHyphen == -1 {
		return fmt.Errorf("invalid archive name format: %s", archiveBaseName)
	}

	baseName := dirName[:lastHyphen]
	extractedDir := filepath.Join(outputDir, dirName)
	targetDir := filepath.Join(outputDir, baseName)

	// Move extracted directory to target
	if err := moveExtractedPackage(extractedDir, targetDir, baseName); err != nil {
		return fmt.Errorf("failed to move extracted package: %w", err)
	}

	// Remove the original archive
	os.Remove(archiveFile)

	return nil
}

// extractZip extracts a zip archive (used for .whl files) to the destination directory.

View on GitHub (pinned to a0bd20f762)

Solutions

  1. Rename the archive to the standard `name-version.tar.gz` sdist layout (e.g. `mypkg-1.0.0.tar.gz`)
  2. Ensure the file was produced by pip, not hand-built, and let pip regenerate it in a clean build
  3. Remove stray non-pip archives from the build output directory

Example fix

// before: build dir contains mypkg.tar.gz
mv mypkg.tar.gz mypkg-1.0.0.tar.gz
// after: glob/derived baseName = "mypkg", extraction proceeds
Defensive patterns

Strategy: validation

Validate before calling

const base = archivePath.split("/").pop()!;
if (!/^.+-[^-]+\.tar\.gz$/.test(base)) throw new Error(`${base} is not name-version.tar.gz`);

Try / catch

try {
  await buildPackage(...);
} catch (e) {
  if (String(e).includes("invalid archive name format")) {
    console.error("Rename archive to <name>-<version>.tar.gz:", e);
  }
  throw e;
}

Prevention

When it happens

Trigger: An archive whose base name contains no `-` (e.g. `package.tar.gz`) was present in the build output and matched one of the glob patterns.

Common situations: A manually created or renamed sdist placed in the build dir (e.g. `mypkg.tar.gz` from `python setup.py sdist` with no version); odd single-token package names.

Related errors


AI-assisted analysis of anomalyco/sst@a0bd20f762 (2026-08-30). Data as JSON: /api/errors/fb66b4bf4fc4159f. Report an issue: GitHub.