anomalyco/sst · error

failed to find package archive: %w

Error message

failed to find package archive: %w

What it means

`extractAndProcessPackageArchive` searches build output with `filepath.Glob` for the downloaded package archive (.whl or .tar.gz). This error wraps an error returned by `filepath.Glob` itself, which only happens when the pattern is malformed (e.g. bad character class or unbalanced brackets), not when no files match.

Source

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

func extractAndProcessPackageArchive(outputDir string, pkg *localPackageInfo) error {
	// Python normalizes package names: dashes become underscores
	normalizedName := strings.ReplaceAll(pkg.Name, "-", "_")

	// Try wheel files first
	patterns := []string{
		filepath.Join(outputDir, normalizedName+"-*.whl"),
		filepath.Join(outputDir, normalizedName+"-*.tar.gz"),
		filepath.Join(outputDir, pkg.Name+"-*.whl"),
		filepath.Join(outputDir, pkg.Name+"-*.tar.gz"),
	}

	var files []string
	var err error

	for _, pattern := range patterns {
		files, err = filepath.Glob(pattern)
		if err != nil {
			return fmt.Errorf("failed to find package archive: %w", err)
		}
		if len(files) > 0 {
			break
		}
	}

	if len(files) == 0 {
		return fmt.Errorf("no package archive found for %s (tried patterns: %s-*.whl, %s-*.tar.gz, %s-*.whl, %s-*.tar.gz)",
			pkg.Name, normalizedName, normalizedName, pkg.Name, pkg.Name)
	}

	// Process each archive file
	for _, archiveFile := range files {
		if err := processPackageArchive(archiveFile, outputDir); err != nil {
			return fmt.Errorf("failed to process archive %s: %w", archiveFile, err)
		}
	}

View on GitHub (pinned to a0bd20f762)

Solutions

  1. Check the package names in the `install` array for glob metacharacters like `[` or `]` and correct or remove them
  2. Run with debug logging to see the exact pattern that failed
  3. Quote/escape or sanitize package names before they reach the build step

Example fix

// before
install: ["reqs[uests"]
// after
install: ["requests"]
Defensive patterns

Strategy: validation

Validate before calling

const bad = pkgNames.filter(n => /[[\]!]/.test(n));
if (bad.length) throw new Error(`Glob-invalid package names: ${bad.join(", ")}`);

Try / catch

try {
  await buildPackage(...);
} catch (e) {
  if (String(e).includes("failed to find package archive")) {
    console.error("Package name contains glob metacharacters:", e);
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling `buildPackage` for a Python function whose `install` list contains a package name with glob-invalid characters (e.g. `[` or `!`) that end up embedded in the search pattern.

Common situations: Hand-edited `sst.config.ts` with a typo in a package name such as `reqs[uests`; package names generated dynamically from user input and injected into the glob pattern.

Related errors


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