{"record":{"id":"5ed08774193d22c6","repo":"dagger/dagger","slug":"llbtodagger-invalid-platform-missing-os-or-archi","errorCode":null,"errorMessage":"llbtodagger: invalid platform: missing OS or architecture","messagePattern":"llbtodagger: invalid platform: missing OS or architecture","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"util/llbtodagger/convert.go","lineNumber":224,"sourceCode":"\nfunc queryContainerID(platform *pb.Platform) (*call.ID, error) {\n\targs := []*call.Argument{}\n\tif platform != nil {\n\t\tplatformStr, err := platformToLiteral(platform)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\targs = append(args, argString(\"platform\", platformStr))\n\t}\n\treturn appendCall(call.New(), containerType(), \"container\", args...), nil\n}\n\nfunc platformToLiteral(platform *pb.Platform) (string, error) {\n\tif platform == nil {\n\t\treturn \"\", nil\n\t}\n\tif platform.OS == \"\" || platform.Architecture == \"\" {\n\t\treturn \"\", fmt.Errorf(\"llbtodagger: invalid platform: missing OS or architecture\")\n\t}\n\tif platform.OSVersion != \"\" || len(platform.OSFeatures) > 0 {\n\t\treturn \"\", fmt.Errorf(\"llbtodagger: unsupported platform fields osVersion/osFeatures\")\n\t}\n\n\tparts := []string{platform.OS, platform.Architecture}\n\tif platform.Variant != \"\" {\n\t\tparts = append(parts, platform.Variant)\n\t}\n\treturn strings.Join(parts, \"/\"), nil\n}\n\nfunc mountSharingEnum(sh pb.CacheSharingOpt) (string, error) {\n\tswitch sh {\n\tcase pb.CacheSharingOpt_SHARED:\n\t\treturn \"SHARED\", nil\n\tcase pb.CacheSharingOpt_PRIVATE:\n\t\treturn \"PRIVATE\", nil","sourceCodeStart":206,"sourceCodeEnd":242,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/util/llbtodagger/convert.go#L206-L242","documentation":"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.","triggerScenarios":"convertExec calls queryContainerID(exec.Platform) with a pb.Platform whose OS field or Architecture field is an empty string.","commonSituations":"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.","solutions":["Populate both OS (e.g. \"linux\") and Architecture (e.g. \"amd64\") on the pb.Platform before running the conversion.","If no platform is intended, pass nil instead of a partially-filled &pb.Platform{} so platformToLiteral returns \"\" without error.","Set platform.OSVersion and platform.OSFeatures to empty as well, or the adjacent unsupported-fields error (5812) will fire."],"exampleFix":"// before\nplat := &pb.Platform{Architecture: \"arm64\"}\n// after\nplat := &pb.Platform{OS: \"linux\", Architecture: \"arm64\"}","handlingStrategy":"validation","validationCode":"func platformValid(p *pb.Platform) bool {\n\tif p == nil { return true }\n\treturn p.OS != \"\" && p.Architecture != \"\" && p.OSVersion == \"\" && len(p.OSFeatures) == 0\n}","typeGuard":"func isCompletePlatform(p *pb.Platform) bool {\n\treturn p != nil && p.OS != \"\" && p.Architecture != \"\"\n}","tryCatchPattern":null,"preventionTips":["Always set both OS and Architecture on pb.Platform structs.","Pass nil instead of a zero-value &pb.Platform{} when no platform is intended.","Derive platform from image metadata with a completeness check."],"tags":["llbtodagger","platform","validation"],"backgroundTag":"invalid-platform","analyzedSha":"82ba2681dbe30d3547a1dc50ea495900ab5b6047","analyzedAt":"2026-09-05T07:21:37.930Z","contentChangedAt":"2026-09-05T07:21:37.930Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}