hyperledger/fabric · error
not a chaincode parameters type: %s
Error message
not a chaincode parameters type: %s
What it means
fetchApprovedChaincodeDefinition validates that the state metadata datatype equals ChaincodeParametersType before deserializing. The stored metadata has a different datatype string, meaning the namespace entry is not chaincode parameters (e.g., it belongs to a token/tokenfilter or other namespace type or is corrupted).
Source
Thrown at core/chaincode/lifecycle/lifecycle.go:623
}
// Fetch the approved chaincode definition
definition, err := ef.fetchApprovedChaincodeDefinition(ccname, sequence, metadata, orgState)
if err != nil {
return nil, errors.WithMessagef(err, "could not fetch approved chaincode definition (name: '%s', sequence: '%d') on channel '%s'", ccname, sequence, chname)
}
definitions[privateName] = definition
}
return definitions, nil
}
func (ef *ExternalFunctions) fetchApprovedChaincodeDefinition(ccname string, sequence int64, metadata *lb.StateMetadata, orgState ReadableState) (*ApprovedChaincodeDefinition, error) {
privateName := fmt.Sprintf("%s#%d", ccname, sequence)
// Verify that metadata type is chaincode parameters type
if metadata.Datatype != ChaincodeParametersType {
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)View on GitHub (pinned to 2736b63f8f)
Solutions
- Verify the chaincode name is correct and does not collide with another namespace in the channel state
- Check the metadata datatype written by the approving peer; re-approve to rewrite correct metadata if corrupted
- Ensure peer and lifecycle library versions match the ledger format in use
Example fix
// before metadata.Datatype == "TOKENS" -> error // after ensure approveformyorg ran so metadata.Datatype == ChaincodeParametersType before querying
Defensive patterns
Strategy: type-guard
Validate before calling
// Check metadata datatype before requesting the definition
md, ok, err := serializer.DeserializeMetadata(lifecycle.NamespacesName, privateName, orgState)
if err != nil || !ok || md.Datatype != lifecycle.ChaincodeParametersType {
return fmt.Errorf("namespace %s is not a chaincode parameters entry (datatype=%v)", privateName, md)
} Type guard
func isChaincodeParametersMetadata(md *lb.StateMetadata) bool {
return md != nil && md.Datatype == lifecycle.ChaincodeParametersType
} Try / catch
def, err := ef.QueryApprovedChaincodeDefinition(ch, ccname, org, seq)
if err != nil && strings.Contains(err.Error(), "not a chaincode parameters type") {
// namespace collision or corrupt metadata; re-approve or fix the name
} Prevention
- Use unique, correct chaincode names to avoid namespace collisions
- Never hand-edit peer state databases
- Keep peer/lifecycle versions aligned with the ledger's datatype schema
When it happens
Trigger: QueryApprovedChaincodeDefinition(s) resolving to a namespace whose stored StateMetadata.Datatype is not CHAINCODE_PARAMETERS — typically a name collision or querying a non-chaincode namespace as a chaincode.
Common situations: Passing a namespace name that collides with another lifecycle-managed namespace; manually edited/corrupted state DB; version-mismatched code reading newer ledger datatypes.
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
- 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'
- requested sequence is 0, but first definable sequence number
AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04).
Data as JSON: /api/errors/00c3bfebb6312356.
Report an issue: GitHub.