{"record":{"id":"02cf94292dc496fa","repo":"hyperledger/fabric","slug":"not-a-chaincode-local-package-type-s","errorCode":null,"errorMessage":"not a chaincode local package type: %s","messagePattern":"not a chaincode local package type: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/chaincode/lifecycle/lifecycle.go","lineNumber":641,"sourceCode":"\t\treturn nil, errors.Errorf(\"not a chaincode parameters type: %s\", metadata.Datatype)\n\t}\n\n\t// Get chaincode parameters for the requested sequence\n\tccParameters := &ChaincodeParameters{}\n\tif err := ef.Resources.Serializer.Deserialize(NamespacesName, privateName, metadata, ccParameters, orgState); err != nil {\n\t\treturn nil, errors.WithMessagef(err, \"could not deserialize chaincode parameters for %s\", privateName)\n\t}\n\n\t// Get package ID for the requested sequence\n\tmetadata, ok, err := ef.Resources.Serializer.DeserializeMetadata(ChaincodeSourcesName, privateName, orgState)\n\tif err != nil {\n\t\treturn nil, errors.WithMessagef(err, \"could not deserialize chaincode-source metadata for %s\", privateName)\n\t}\n\tif !ok {\n\t\treturn nil, errors.Errorf(\"could not fetch chaincode-source metadata for %s\", privateName)\n\t}\n\tif metadata.Datatype != ChaincodeLocalPackageType {\n\t\treturn nil, errors.Errorf(\"not a chaincode local package type: %s\", metadata.Datatype)\n\t}\n\n\tccLocalPackage := &ChaincodeLocalPackage{}\n\tif err := ef.Resources.Serializer.Deserialize(ChaincodeSourcesName, privateName, metadata, ccLocalPackage, orgState); err != nil {\n\t\treturn nil, errors.WithMessagef(err, \"could not deserialize chaincode package for %s\", privateName)\n\t}\n\n\t// Convert to lb.ChaincodeSource\n\t// An empty package ID means that the chaincode won't be invocable\n\tvar ccsrc *lb.ChaincodeSource\n\tif ccLocalPackage.PackageID != \"\" {\n\t\tccsrc = &lb.ChaincodeSource{\n\t\t\tType: &lb.ChaincodeSource_LocalPackage{\n\t\t\t\tLocalPackage: &lb.ChaincodeSource_Local{\n\t\t\t\t\tPackageId: ccLocalPackage.PackageID,\n\t\t\t\t},\n\t\t\t},\n\t\t}","sourceCodeStart":623,"sourceCodeEnd":659,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/chaincode/lifecycle/lifecycle.go#L623-L659","documentation":"After metadata for the chaincode-source key is found, lifecycle checks that its Datatype equals ChaincodeLocalPackageType. If a different record type is stored under that key, the peer refuses to interpret it as a local package and throws this error. It indicates corrupted or wrong-typed state under the chaincode-sources namespace in the org's private data state.","triggerScenarios":"fetchApprovedChaincodeDefinition deserializes metadata for <name>#<sequence> whose Datatype is not ChaincodeLocalPackageType, typically due to corrupted lifecycle state or a version mismatch writing different record types under the same key.","commonSituations":"Peer state corrupted by a failed/partial upgrade or state restore from a different Fabric version; manual DB manipulation of the private collection state; mixed peer versions in the same org.","solutions":["Inspect and repair peer state; if the package state is corrupt, re-run approveformyorg with a valid package-id","Restore the peer from a clean ledger snapshot or rejoin the peer to the channel to rebuild state","Ensure all peers in the org run a consistent Fabric version","Never manually edit the peer's state database"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Validate lifecycle state health: compare committed sequence with queried sequence\n// peer lifecycle chaincode querycommitted -C mychannel --name mycc\nconst committedSeq = committed.sequence;\nif (requestedSeq > committedSeq + 1) throw new Error('sequence too far ahead; approval state likely stale');","typeGuard":null,"tryCatchPattern":"try {\n  def := lifecycle.QueryApprovedChaincodeDefinition(channel, name, seq)\n} catch (err) {\n  if strings.Contains(err.Error(), \"not a chaincode local package type\") {\n    // flag peer state corruption; escalate to re-approval/restore\n  }\n}","preventionTips":["Never manually edit peer state DBs","Keep all peers in an org on the same Fabric version","Maintain peer backups for state restoration","Re-approve cleanly rather than patching state"],"tags":["fabric","lifecycle","state-corruption","metadata-type"],"backgroundTag":"schema-validation-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"}