{"record":{"id":"531cee0d8f633891","repo":"hyperledger/fabric","slug":"failed-to-generate-platform-specific-dockerfile","errorCode":null,"errorMessage":"Failed to generate platform-specific Dockerfile: %s","messagePattern":"Failed to generate platform-specific Dockerfile: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/chaincode/platforms/platforms.go","lineNumber":91,"sourceCode":"\t\tPackageWriter: PackageWriterWrapper(writeBytesToPackage),\n\t\tDockerBuild:   util.DockerBuild,\n\t}\n}\n\nfunc (r *Registry) GenerateDockerfile(ccType string) (string, error) {\n\tplatform, ok := r.Platforms[ccType]\n\tif !ok {\n\t\treturn \"\", fmt.Errorf(\"Unknown chaincodeType: %s\", ccType)\n\t}\n\n\tvar buf []string\n\n\t// ----------------------------------------------------------------------------------------------------\n\t// Let the platform define the base Dockerfile\n\t// ----------------------------------------------------------------------------------------------------\n\tbase, err := platform.GenerateDockerfile()\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"Failed to generate platform-specific Dockerfile: %s\", err)\n\t}\n\tbuf = append(buf, base)\n\tbuf = append(buf, fmt.Sprintf(`LABEL %s.chaincode.type=\"%s\" \\`, metadata.BaseDockerLabel, ccType))\n\tbuf = append(buf, fmt.Sprintf(`      %s.version=\"%s\"`, metadata.BaseDockerLabel, metadata.Version))\n\t// ----------------------------------------------------------------------------------------------------\n\t// Then augment it with any general options\n\t// ----------------------------------------------------------------------------------------------------\n\t// append version so chaincode build version can be compared against peer build version\n\tbuf = append(buf, fmt.Sprintf(\"ENV CORE_CHAINCODE_BUILDLEVEL=%s\", metadata.Version))\n\n\t// ----------------------------------------------------------------------------------------------------\n\t// Finalize it\n\t// ----------------------------------------------------------------------------------------------------\n\tcontents := strings.Join(buf, \"\\n\")\n\tlogger.Debugf(\"\\n%s\", contents)\n\n\treturn contents, nil\n}","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/chaincode/platforms/platforms.go#L73-L109","documentation":"After resolving the platform for the chaincode type, GenerateDockerfile calls that platform's GenerateDockerfile() to produce its base Dockerfile. If the platform-level generation fails (its own internal error), the registry wraps it as 'Failed to generate platform-specific Dockerfile'. The root cause is inside the specific platform's Dockerfile generation logic.","triggerScenarios":"GenerateDockerBuild -> GenerateDockerfile -> platform.GenerateDockerfile() returning an error — e.g. a node/go platform failing to determine its base image or internal template error.","commonSituations":"Custom or patched Fabric builds where platform internals fail, environment misconfigurations affecting base-image selection, or version incompatibilities in platform metadata used while composing the Dockerfile.","solutions":["Read the wrapped underlying error in the message/logs for the platform-specific root cause.","Verify Fabric installation integrity (the platform's static Dockerfile generation should not normally fail).","Check that metadata (BaseDockerLabel, Version) matches the Fabric version in use.","Rebuild/redeploy with a stock Fabric build to rule out customization issues."],"exampleFix":"// before: custom registry with patched node platform\nregistry.Register(pb.ChaincodeSpec_NODE, customNodePlatform{})\n// after: use stock platform\nregistry.Register(pb.ChaincodeSpec_NODE, &node.Platform{})","handlingStrategy":"try-catch","validationCode":"// ensure the platform is registered and metadata is intact before building\nif (!registry.Platforms[ccType]) { throw new Error('platform not registered'); }","typeGuard":null,"tryCatchPattern":"try {\n  dockerfile, err = registry.GenerateDockerfile(ccType)\n} catch (err) {\n  if (/Failed to generate platform-specific Dockerfile/.test(err.message)) {\n    // inspect wrapped cause; fall back to stock Fabric platform implementation\n  }\n  throw err\n}","preventionTips":["Run stock Fabric builds unless platform customization is intentional","Keep Fabric metadata/labels consistent with the deployed version","Log and inspect the wrapped inner error","Test dockerfile generation in CI before production installs"],"tags":["chaincode","docker","dockerfile","platform"],"backgroundTag":"dockerfile-generation-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"}