{"record":{"id":"011f0f137ca7def2","repo":"hyperledger/fabric","slug":"not-a-chaincode-type-s","errorCode":null,"errorMessage":"not a chaincode type: %s","messagePattern":"not a chaincode type: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/chaincode/lifecycle/lifecycle.go","lineNumber":262,"sourceCode":"\t\treturn true, &ChaincodeDefinition{\n\t\t\tEndorsementInfo: &lb.ChaincodeEndorsementInfo{\n\t\t\t\tInitRequired: false,\n\t\t\t},\n\t\t\tValidationInfo: &lb.ChaincodeValidationInfo{},\n\t\t}, nil\n\t}\n\n\tmetadata, ok, err := r.Serializer.DeserializeMetadata(NamespacesName, chaincodeName, state)\n\tif err != nil {\n\t\treturn false, nil, errors.WithMessagef(err, \"could not deserialize metadata for chaincode %s\", chaincodeName)\n\t}\n\n\tif !ok {\n\t\treturn false, nil, nil\n\t}\n\n\tif metadata.Datatype != ChaincodeDefinitionType {\n\t\treturn false, nil, errors.Errorf(\"not a chaincode type: %s\", metadata.Datatype)\n\t}\n\n\tdefinedChaincode := &ChaincodeDefinition{}\n\terr = r.Serializer.Deserialize(NamespacesName, chaincodeName, metadata, definedChaincode, state)\n\tif err != nil {\n\t\treturn false, nil, errors.WithMessagef(err, \"could not deserialize chaincode definition for chaincode %s\", chaincodeName)\n\t}\n\n\treturn true, definedChaincode, nil\n}\n\nfunc (r *Resources) LifecycleEndorsementPolicyAsBytes(channelID string) ([]byte, error) {\n\tchannelConfig := r.ChannelConfigSource.GetStableChannelConfig(channelID)\n\tif channelConfig == nil {\n\t\treturn nil, errors.Errorf(\"could not get channel config for channel '%s'\", channelID)\n\t}\n\n\tif _, ok := channelConfig.PolicyManager().GetPolicy(LifecycleEndorsementPolicyRef); ok {","sourceCodeStart":244,"sourceCodeEnd":280,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/chaincode/lifecycle/lifecycle.go#L244-L280","documentation":"Thrown by ChaincodeDefinitionIfDefined when the namespace metadata found in the lifecycle state has a Datatype other than ChaincodeDefinitionType, meaning the requested name exists in the lifecycle namespace but is not a chaincode definition (e.g. it is a collection or other namespace entry).","triggerScenarios":"Calling QueryChaincodeDefinition / ChaincodeInfo / CollectionInfo / ValidationInfo / ImplicitCollections for a name that maps to a non-chaincode metadata type in the lifecycle state store.","commonSituations":"Querying a private collection name as if it were a chaincode; typos in the chaincode name colliding with another namespace entry; corrupted or hand-edited lifecycle state on the peer.","solutions":["Verify the chaincode name is correct and actually approved/committed as a chaincode","Use 'peer lifecycle chaincode querycommitted' to list real committed chaincodes on the channel","Check the peer's lifecycle state (couchdb/leveldb) for corruption if the name should be a chaincode"],"exampleFix":"// before\nChaincodeInfo(channel: 'ch1', name: 'mycc_private_collection') // not a chaincode type\n// after\nChaincodeInfo(channel: 'ch1', name: 'mycc') // use the chaincode name, not the collection name","handlingStrategy":"type-guard","validationCode":"ok, metadata, err := lifecycleQueryNamespaceMetadata(chname, ccname, state)\nif err != nil { return err }\nif ok && metadata.Datatype != lifecycle.ChaincodeDefinitionType {\n    return fmt.Errorf(\"%s is not a chaincode namespace\", ccname)\n}","typeGuard":"func isChaincodeDefinition(metadata *lb.StateMetadata) bool {\n    return metadata != nil && metadata.Datatype == lifecycle.ChaincodeDefinitionType\n}","tryCatchPattern":"_, def, err := resources.ChaincodeDefinitionIfDefined(ccname)\nif err != nil {\n    if strings.Contains(err.Error(), \"not a chaincode type\") {\n        // wrong namespace: check whether ccname is a collection or other entry\n    }\n    return err\n}","preventionTips":["Only query chaincode definitions with actual chaincode names, not collection names","List committed chaincodes with querycommitted before querying a definition","Never hand-edit lifecycle state storage on peers"],"tags":["hyperledger-fabric","lifecycle","namespace","wrong-type"],"backgroundTag":"namespace-type-mismatch","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"}