{"record":{"id":"00c3bfebb6312356","repo":"hyperledger/fabric","slug":"not-a-chaincode-parameters-type-s","errorCode":null,"errorMessage":"not a chaincode parameters type: %s","messagePattern":"not a chaincode parameters type: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/chaincode/lifecycle/lifecycle.go","lineNumber":623,"sourceCode":"\t\t}\n\n\t\t// Fetch the approved chaincode definition\n\t\tdefinition, err := ef.fetchApprovedChaincodeDefinition(ccname, sequence, metadata, orgState)\n\t\tif err != nil {\n\t\t\treturn nil, errors.WithMessagef(err, \"could not fetch approved chaincode definition (name: '%s', sequence: '%d') on channel '%s'\", ccname, sequence, chname)\n\t\t}\n\n\t\tdefinitions[privateName] = definition\n\t}\n\n\treturn definitions, nil\n}\n\nfunc (ef *ExternalFunctions) fetchApprovedChaincodeDefinition(ccname string, sequence int64, metadata *lb.StateMetadata, orgState ReadableState) (*ApprovedChaincodeDefinition, error) {\n\tprivateName := fmt.Sprintf(\"%s#%d\", ccname, sequence)\n\t// Verify that metadata type is chaincode parameters type\n\tif metadata.Datatype != ChaincodeParametersType {\n\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)","sourceCodeStart":605,"sourceCodeEnd":641,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/chaincode/lifecycle/lifecycle.go#L605-L641","documentation":"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).","triggerScenarios":"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.","commonSituations":"Passing a namespace name that collides with another lifecycle-managed namespace; manually edited/corrupted state DB; version-mismatched code reading newer ledger datatypes.","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"],"exampleFix":"// before\nmetadata.Datatype == \"TOKENS\" -> error\n// after\nensure approveformyorg ran so metadata.Datatype == ChaincodeParametersType before querying","handlingStrategy":"type-guard","validationCode":"// Check metadata datatype before requesting the definition\nmd, ok, err := serializer.DeserializeMetadata(lifecycle.NamespacesName, privateName, orgState)\nif err != nil || !ok || md.Datatype != lifecycle.ChaincodeParametersType {\n    return fmt.Errorf(\"namespace %s is not a chaincode parameters entry (datatype=%v)\", privateName, md)\n}","typeGuard":"func isChaincodeParametersMetadata(md *lb.StateMetadata) bool {\n    return md != nil && md.Datatype == lifecycle.ChaincodeParametersType\n}","tryCatchPattern":"def, err := ef.QueryApprovedChaincodeDefinition(ch, ccname, org, seq)\nif err != nil && strings.Contains(err.Error(), \"not a chaincode parameters type\") {\n    // namespace collision or corrupt metadata; re-approve or fix the name\n}","preventionTips":["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"],"tags":["fabric","lifecycle","datatype"],"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"}