github/copilot-sdk · error

invalid platform

Error message

invalid platform %q

What it means

resolvePlatform validates the bundler's --platform flag, which must be in GOOS/GOARCH form (e.g. linux/amd64). This instance fires when the value cannot be split on '/' into a non-empty GOOS and GOARCH. Both invalid-format and unknown-platform cases return the same message.

Solutions

  1. Use the full GOOS/GOARCH form, e.g. --platform linux/amd64 or --platform darwin/arm64.
  2. Quote the flag value in the shell to prevent splitting: --platform "linux/amd64".
  3. Check the platforms map in go/cmd/bundler/main.go for the list of supported platform strings.
  4. Print the parsed value (echo of args) to confirm the flag actually received both parts.

Example fix

// before
bundler --platform linux

// after
bundler --platform linux/amd64
Defensive patterns

Strategy: validation

Validate before calling

func validPlatformFormat(p string) bool {
    goos, goarch, ok := strings.Cut(p, "/")
    return ok && goos != "" && goarch != ""
}

Try / catch

goos, goarch, info, err := resolvePlatform(*platformFlag)
if err != nil {
    log.Fatalf("--platform must be GOOS/GOARCH (e.g. linux/amd64): %v", err)
}

Prevention

When it happens

Trigger: Running the bundler with a --platform value lacking a '/' separator, or with empty GOOS or GOARCH parts (e.g. --platform linux, --platform /amd64, --platform linux/).

Common situations: Typos like 'linux amd64' (space instead of slash); passing only the OS name; copying a Docker-style platform tag such as 'linux' alone; shell mangling 'linux/amd64' (unquoted in some contexts is fine, but quoting mistakes drop part of the value).

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


AI-assisted analysis of github/copilot-sdk@cd8cf15dc3 (2026-09-09). Data as JSON: /api/errors/fea09598dda827da. Report an issue: GitHub.

Appendix: source

Thrown at go/cmd/bundler/main.go:167

		muslBundle.assetsArtifactPath,
		muslBundle.assetsHash,
		pkgName,
	); err != nil {
		fmt.Fprintf(os.Stderr, "Error: %v\n", err)
		os.Exit(1)
	}

	if err := ensureZstdDependency(); err != nil {
		fmt.Fprintf(os.Stderr, "Error: %v\n", err)
		os.Exit(1)
	}
}

// resolvePlatform validates the platform flag and returns GOOS/GOARCH and mapping info.
func resolvePlatform(platform string) (string, string, platformInfo, error) {
	goos, goarch, ok := strings.Cut(platform, "/")
	if !ok || goos == "" || goarch == "" {
		return "", "", platformInfo{}, fmt.Errorf("invalid platform %q", platform)
	}
	info, ok := platforms[platform]
	if !ok {
		return "", "", platformInfo{}, fmt.Errorf("invalid platform %q", platform)
	}
	return goos, goarch, info, nil
}

// resolveCLIVersion determines the CLI version from the flag or repo metadata.
func resolveCLIVersion(flagValue string) string {
	if flagValue != "" {
		return flagValue
	}
	version, err := detectCLIVersion()
	if err != nil {
		fmt.Fprintf(os.Stderr, "Error detecting CLI version: %v\n", err)
		fmt.Fprintln(os.Stderr, "Hint: specify --cli-version explicitly, or run from a Go module that depends on github.com/github/copilot-sdk/go")
		os.Exit(1)

View on GitHub (pinned to cd8cf15dc3)