{"record":{"id":"0bc489142d863f2a","repo":"hyperledger/fabric","slug":"platform-builder-failed","errorCode":null,"errorMessage":"platform builder failed","messagePattern":"platform builder failed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/container/dockercontroller/dockercontroller.go","lineNumber":158,"sourceCode":"}\n\n// Build is responsible for building an image if it does not already exist.\nfunc (vm *DockerVM) Build(ccid string, metadata *persistence.ChaincodePackageMetadata, codePackage io.Reader) (container.Instance, error) {\n\timageName, err := vm.GetVMNameForDocker(ccid)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// This is an awkward translation, but better here in a future dead path\n\t// than elsewhere.  The old enum types are capital, but at least as implemented\n\t// lifecycle tools seem to allow type to be set lower case.\n\tccType := strings.ToUpper(metadata.Type)\n\n\t_, err = vm.Client.ImageInspect(context.Background(), imageName)\n\tif err != nil && strings.Contains(err.Error(), \"No such image\") {\n\t\tdockerfileReader, err := vm.PlatformBuilder.GenerateDockerBuild(ccType, metadata.Path, codePackage)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrap(err, \"platform builder failed\")\n\t\t}\n\t\terr = vm.buildImage(ccid, dockerfileReader)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrap(err, \"docker image build failed\")\n\t\t}\n\t} else if err != nil {\n\t\treturn nil, errors.Wrap(err, \"docker image inspection failed\")\n\t}\n\n\treturn &ContainerInstance{\n\t\tDockerVM: vm,\n\t\tCCID:     ccid,\n\t\tType:     ccType,\n\t}, nil\n}\n\n// In order to support starting chaincode containers built with Fabric v1.4 and earlier,\n// we must check for the precense of the start.sh script for Node.js chaincode before","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/container/dockercontroller/dockercontroller.go#L140-L176","documentation":"Thrown by DockerVM.Build in Hyperledger Fabric's dockercontroller when vm.PlatformBuilder.GenerateDockerBuild fails to produce the Docker build context for a chaincode package. The platform-specific builder (Golang/Node/Java) inspects and rewrites the chaincode source tarball into a Dockerfile tar stream; any failure reading the package, recognizing the chaincode type, or assembling the build context is wrapped here. It means the chaincode image was never attempted to be built because the build input could not be generated.","triggerScenarios":"Calling Build (or installing/approving a chaincode package which eventually calls it) when: the code package tarball is corrupt or truncated; metadata.Path points to a missing directory inside the package; metadata.Type is not recognized by the platform registry; or the platform builder errors parsing the package contents.","commonSituations":"Deploying chaincode with a package whose metadata.Type is misspelled or lowercase in a form the builder registry rejects; an empty or malformed package produced by an older peer lifecycle tool; packages built for a different Fabric version whose layout the current platform builder does not expect.","solutions":["Verify the chaincode package metadata (Type, Path) matches the actual package contents; repackage the chaincode with the correct --lang and path.","Rebuild the chaincode package with the current peer's lifecycle tooling (peer lifecycle chaincode package) so the tar layout is compatible.","Enable debug logging on the peer and inspect the wrapped underlying error for the exact platform-builder failure (e.g. missing file, unsupported type).","Check that the chaincode language is supported (GOLANG/JAVA/NODE) and that the source path exists inside the package."],"exampleFix":"// before: package created with mismatched lang\npeer lifecycle chaincode package cc.tar.gz --path ./src --lang golang --label cc_1  // path wrong, no go sources there\n// after\npeer lifecycle chaincode package cc.tar.gz --path ./chaincode --lang golang --label cc_1","handlingStrategy":"validation","validationCode":"func validatePackage(meta *persistence.ChaincodePackageMetadata, pkg io.Reader) error {\n\tif meta == nil || meta.Type == \"\" || meta.Path == \"\" {\n\t\treturn errors.New(\"chaincode package metadata incomplete\")\n\t}\n\tswitch strings.ToUpper(meta.Type) {\n\tcase \"GOLANG\", \"JAVA\", \"NODE\", \"CAR\":\n\tdefault:\n\t\treturn fmt.Errorf(\"unsupported chaincode type: %s\", meta.Type)\n\t}\n\treturn nil\n}","typeGuard":"func isSupportedType(t string) bool {\n\tswitch strings.ToUpper(t) {\n\tcase \"GOLANG\", \"JAVA\", \"NODE\", \"CAR\":\n\t\treturn true\n\t}\n\treturn false\n}","tryCatchPattern":"inst, err := vm.Build(ccid, meta, codePackage)\nif err != nil {\n\tif strings.Contains(err.Error(), \"platform builder failed\") {\n\t\t// repackage chaincode or fix metadata.Type/Path, then retry\n\t}\n\treturn fmt.Errorf(\"chaincode deploy aborted: %w\", err)\n}","preventionTips":["Always package chaincode with peer lifecycle chaincode package using the current peer version.","Validate metadata.Type is a supported language and Path exists before install.","Enable peer debug logging during deploys to capture the wrapped builder error early."],"tags":["hyperledger-fabric","chaincode-build","docker","go"],"backgroundTag":"chaincode-package-build-failed","analyzedSha":"2736b63f8fd5932511d56fe68b7039d15977f7f6","analyzedAt":"2026-09-04T08:52:36.465Z","contentChangedAt":"2026-09-04T08:52:36.465Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}