dagger/dagger · error

llbtodagger: invalid platform: missing OS or architecture

Error message

llbtodagger: invalid platform: missing OS or architecture

What it means

platformToLiteral serializes a Buildkit pb.Platform into a Dagger platform literal string (os/arch[/variant]). A platform missing either the OS or the Architecture component cannot form a valid OCI platform string, so it is rejected.

Source

Thrown at util/llbtodagger/convert.go:224

func queryContainerID(platform *pb.Platform) (*call.ID, error) {
	args := []*call.Argument{}
	if platform != nil {
		platformStr, err := platformToLiteral(platform)
		if err != nil {
			return nil, err
		}
		args = append(args, argString("platform", platformStr))
	}
	return appendCall(call.New(), containerType(), "container", args...), nil
}

func platformToLiteral(platform *pb.Platform) (string, error) {
	if platform == nil {
		return "", nil
	}
	if platform.OS == "" || platform.Architecture == "" {
		return "", fmt.Errorf("llbtodagger: invalid platform: missing OS or architecture")
	}
	if platform.OSVersion != "" || len(platform.OSFeatures) > 0 {
		return "", fmt.Errorf("llbtodagger: unsupported platform fields osVersion/osFeatures")
	}

	parts := []string{platform.OS, platform.Architecture}
	if platform.Variant != "" {
		parts = append(parts, platform.Variant)
	}
	return strings.Join(parts, "/"), nil
}

func mountSharingEnum(sh pb.CacheSharingOpt) (string, error) {
	switch sh {
	case pb.CacheSharingOpt_SHARED:
		return "SHARED", nil
	case pb.CacheSharingOpt_PRIVATE:
		return "PRIVATE", nil

View on GitHub (pinned to 82ba2681db)

Solutions

  1. Populate both OS (e.g. "linux") and Architecture (e.g. "amd64") on the pb.Platform before running the conversion.
  2. If no platform is intended, pass nil instead of a partially-filled &pb.Platform{} so platformToLiteral returns "" without error.
  3. Set platform.OSVersion and platform.OSFeatures to empty as well, or the adjacent unsupported-fields error (5812) will fire.

Example fix

// before
plat := &pb.Platform{Architecture: "arm64"}
// after
plat := &pb.Platform{OS: "linux", Architecture: "arm64"}
Defensive patterns

Strategy: validation

Validate before calling

func platformValid(p *pb.Platform) bool {
	if p == nil { return true }
	return p.OS != "" && p.Architecture != "" && p.OSVersion == "" && len(p.OSFeatures) == 0
}

Type guard

func isCompletePlatform(p *pb.Platform) bool {
	return p != nil && p.OS != "" && p.Architecture != ""
}

Prevention

When it happens

Trigger: convertExec calls queryContainerID(exec.Platform) with a pb.Platform whose OS field or Architecture field is an empty string.

Common situations: LLB ops produced by tools that only partially populate platform metadata; hand-built pb.Platform structs in tests or custom frontends omitting Architecture; platform structs copied from metadata sources that set only Variant.

Related errors


AI-assisted analysis of dagger/dagger@82ba2681db (2026-09-05). Data as JSON: /api/errors/5ed08774193d22c6. Report an issue: GitHub.