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
- Use the full GOOS/GOARCH form, e.g. --platform linux/amd64 or --platform darwin/arm64.
- Quote the flag value in the shell to prevent splitting: --platform "linux/amd64".
- Check the platforms map in go/cmd/bundler/main.go for the list of supported platform strings.
- 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
- Always pass GOOS/GOARCH with a slash; quote the flag in shell scripts.
- Shell-complete or hardcode platform values in CI pipelines.
- Document accepted values next to the flag usage.
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
- SessionFS.SessionStatePath is required
- SessionFS.Conventions must be either 'posix' or 'windows'
- in-process transport unavailable: rebuild with -tags…
- in-process transport unavailable
- Client is in Mode=ModeEmpty but the session config did not…
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)