{"record":{"id":"b826978089ec5010","repo":"hyperledger/fabric","slug":"did-not-find-any-package-metadata-missing-s","errorCode":null,"errorMessage":"did not find any package metadata (missing %s)","messagePattern":"did not find any package metadata \\(missing (.+?)\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/chaincode/persistence/chaincode_package.go","lineNumber":331,"sourceCode":"\t\t\tccPackageMetadata = &ChaincodePackageMetadata{}\n\t\t\terr := json.Unmarshal(fileBytes, ccPackageMetadata)\n\t\t\tif err != nil {\n\t\t\t\treturn ccPackageMetadata, nil, errors.Wrapf(err, \"could not unmarshal %s as json\", MetadataFile)\n\t\t\t}\n\n\t\tcase CodePackageFile:\n\t\t\tcodePackage = fileBytes\n\t\tdefault:\n\t\t\tlogger.Warningf(\"Encountered unexpected file '%s' in top level of chaincode package\", header.Name)\n\t\t}\n\t}\n\n\tif codePackage == nil {\n\t\treturn ccPackageMetadata, nil, errors.Errorf(\"did not find a code package inside the package\")\n\t}\n\n\tif ccPackageMetadata == nil {\n\t\treturn ccPackageMetadata, nil, errors.Errorf(\"did not find any package metadata (missing %s)\", MetadataFile)\n\t}\n\n\tif err := ValidateLabel(ccPackageMetadata.Label); err != nil {\n\t\treturn ccPackageMetadata, nil, err\n\t}\n\n\treturn ccPackageMetadata, codePackage, nil\n}\n","sourceCodeStart":313,"sourceCodeEnd":340,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/chaincode/persistence/chaincode_package.go#L313-L340","documentation":"ParseChaincodePackage requires a metadata member (MetadataFile, i.e. metadata.json) at the top level of the chaincode package archive. If the archive contains a code package but no metadata entry, ccPackageMetadata stays nil and this error is thrown.","triggerScenarios":"Calling Parse or PackageID on a tar archive that contains the code payload but is missing the metadata.json top-level file, or where metadata.json failed to parse and was skipped (metadata parse errors also leave ccPackageMetadata nil).","commonSituations":"Manually assembled packages missing metadata.json; packages built with an incompatible/older tool version; archive corrupted so the metadata entry name does not match exactly.","solutions":["Repackage using `peer lifecycle chaincode package` so metadata.json is emitted at the archive top level","Inspect the archive (`tar -tf`) and confirm a top-level metadata.json exists with the exact expected name","If building packages programmatically, serialize PackageMetadata {Type, Path, Label} to metadata.json and add it to the tarball before the code package"],"exampleFix":"// before\n// tar: code.tar.gz only\n\n// after\n// tar: metadata.json (contains {\"Type\":\"golang\",\"Path\":\"./src\",\"Label\":\"mycc_1.0\"}), label, code.tar.gz","handlingStrategy":"validation","validationCode":"entries, _ := listTarTopLevel(pkgBytes)\nif !slices.Contains(entries, \"metadata.json\") {\n    return errors.New(\"chaincode package is missing metadata.json\")\n}","typeGuard":"func hasMetadata(entries []string) bool { return slices.Contains(entries, \"metadata.json\") }","tryCatchPattern":"ccPackage, digest, err := parser.Parse(pkgBytes)\nif err != nil {\n    if strings.Contains(err.Error(), \"did not find any package metadata\") {\n        return fmt.Errorf(\"rebuild package with metadata.json: %w\", err)\n    }\n    return err\n}","preventionTips":["Never strip metadata.json when re-tarring or re-exporting packages","Use the same fabric-tools version across environments to keep package format consistent","Validate packages in CI before publishing them to install pipelines"],"tags":["chaincode","packaging","metadata"],"backgroundTag":"missing-package-metadata","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"}