{"record":{"id":"617b96d93425febb","repo":"hyperledger/fabric","slug":"empty-metadata-for-supplied-chaincode","errorCode":null,"errorMessage":"empty metadata for supplied chaincode","messagePattern":"empty metadata for supplied chaincode","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/chaincode/lifecycle/lifecycle.go","lineNumber":764,"sourceCode":"\t\tif len(mismatchItems) > 0 {\n\t\t\tmismatches[org] = mismatchItems\n\t\t}\n\t}\n\n\treturn\n}\n\n// InstallChaincode installs a given chaincode to the peer's chaincode store.\n// It returns the hash to reference the chaincode by or an error on failure.\nfunc (ef *ExternalFunctions) InstallChaincode(chaincodeInstallPackage []byte) (*chaincode.InstalledChaincode, error) {\n\t// Let's validate that the chaincodeInstallPackage is at least well formed before writing it\n\tpkg, err := ef.Resources.PackageParser.Parse(chaincodeInstallPackage)\n\tif err != nil {\n\t\treturn nil, errors.WithMessage(err, \"could not parse as a chaincode install package\")\n\t}\n\n\tif pkg.Metadata == nil {\n\t\treturn nil, errors.New(\"empty metadata for supplied chaincode\")\n\t}\n\n\tpackageID, err := ef.Resources.ChaincodeStore.Save(pkg.Metadata.Label, chaincodeInstallPackage)\n\tif err != nil {\n\t\treturn nil, errors.WithMessage(err, \"could not save cc install package\")\n\t}\n\n\tbuildLock, cleanupBuildLocks := ef.getBuildLock(packageID)\n\tdefer cleanupBuildLocks()\n\n\tbuildLock.Lock()\n\tdefer buildLock.Unlock()\n\n\tbuildStatus, ok := ef.BuildRegistry.BuildStatus(packageID)\n\tif ok {\n\t\t// another invocation of lifecycle has concurrently\n\t\t// installed a chaincode with this package id\n\t\t<-buildStatus.Done()","sourceCodeStart":746,"sourceCodeEnd":782,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/chaincode/lifecycle/lifecycle.go#L746-L782","documentation":"InstallChaincode first parses the submitted package with PackageParser.Parse. If the parsed package has no Metadata, the file is not a valid lifecycle chaincode install package and this error is thrown. The package tarball lacks the required metadata.json entry.","triggerScenarios":"Calling 'peer lifecycle chaincode install' with a file that is not a packaged chaincode (e.g. a raw tar.gz without metadata.json, a legacy-BCS .car file, or a truncated download).","commonSituations":"Passing the source archive instead of the peer lifecycle package output; corrupted transfer; using old lifecycle (v1.x) deployment artifacts with the new lifecycle; wrong --path/--lang packaging.","solutions":["Repackage with 'peer lifecycle chaincode package mycc.tar.gz --path <src> --lang <lang> --label mycc_1.0'","Verify the tarball contains metadata.json (with type/label/path) at its root and is not truncated","Use the exact file produced by the package command for install on all peers","Check you are not mixing v1.x '.car'/chaincode-spec artifacts with v2.x lifecycle packages"],"exampleFix":"// before: installing a raw source archive\npeer lifecycle chaincode install chaincode.tar.gz\n// error: empty metadata for supplied chaincode\n// after: package first, then install\npeer lifecycle chaincode package mycc.tar.gz --path ./chaincode --lang golang --label mycc_1.0\npeer lifecycle chaincode install mycc.tar.gz","handlingStrategy":"validation","validationCode":"// Before install, verify the package contains metadata.json:\ntar -tzf mycc.tar.gz | grep '^metadata.json$' || echo 'invalid lifecycle package'","typeGuard":null,"tryCatchPattern":"try {\n  lifecycle.InstallChaincode(pkgBytes)\n} catch (err) {\n  if strings.Contains(err.Error(), \"empty metadata for supplied chaincode\") {\n    // repackage the chaincode before retrying\n  }\n}","preventionTips":["Always install the artifact produced by 'peer lifecycle chaincode package'","Never pass raw source archives or v1.x .car files to v2 lifecycle install","Verify tarball contents include metadata.json","Checksum packages distributed to peers"],"tags":["fabric","lifecycle","install","package-format"],"backgroundTag":"invalid-chaincode-package","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"}