hyperledger/fabric · error
not a chaincode local package type: %s
Error message
not a chaincode local package type: %s
What it means
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.
Source
Thrown at core/chaincode/lifecycle/lifecycle.go:641
return nil, errors.Errorf("not a chaincode parameters type: %s", metadata.Datatype)
}
// Get chaincode parameters for the requested sequence
ccParameters := &ChaincodeParameters{}
if err := ef.Resources.Serializer.Deserialize(NamespacesName, privateName, metadata, ccParameters, orgState); err != nil {
return nil, errors.WithMessagef(err, "could not deserialize chaincode parameters for %s", privateName)
}
// Get package ID for the requested sequence
metadata, ok, err := ef.Resources.Serializer.DeserializeMetadata(ChaincodeSourcesName, privateName, orgState)
if err != nil {
return nil, errors.WithMessagef(err, "could not deserialize chaincode-source metadata for %s", privateName)
}
if !ok {
return nil, errors.Errorf("could not fetch chaincode-source metadata for %s", privateName)
}
if metadata.Datatype != ChaincodeLocalPackageType {
return nil, errors.Errorf("not a chaincode local package type: %s", metadata.Datatype)
}
ccLocalPackage := &ChaincodeLocalPackage{}
if err := ef.Resources.Serializer.Deserialize(ChaincodeSourcesName, privateName, metadata, ccLocalPackage, orgState); err != nil {
return nil, errors.WithMessagef(err, "could not deserialize chaincode package for %s", privateName)
}
// Convert to lb.ChaincodeSource
// An empty package ID means that the chaincode won't be invocable
var ccsrc *lb.ChaincodeSource
if ccLocalPackage.PackageID != "" {
ccsrc = &lb.ChaincodeSource{
Type: &lb.ChaincodeSource_LocalPackage{
LocalPackage: &lb.ChaincodeSource_Local{
PackageId: ccLocalPackage.PackageID,
},
},
}View on GitHub (pinned to 2736b63f8f)
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
Defensive patterns
Strategy: try-catch
Validate before calling
// Validate lifecycle state health: compare committed sequence with queried sequence
// peer lifecycle chaincode querycommitted -C mychannel --name mycc
const committedSeq = committed.sequence;
if (requestedSeq > committedSeq + 1) throw new Error('sequence too far ahead; approval state likely stale'); Try / catch
try {
def := lifecycle.QueryApprovedChaincodeDefinition(channel, name, seq)
} catch (err) {
if strings.Contains(err.Error(), "not a chaincode local package type") {
// flag peer state corruption; escalate to re-approval/restore
}
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- invalid private name format: %s
- query iterator not found
- application config does not exist for channel '%s'
- unknown chaincode '%s' for channel '%s'
- could not find chaincode with package id '%s'
AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04).
Data as JSON: /api/errors/02cf94292dc496fa.
Report an issue: GitHub.