{"record":{"id":"f7925089af4f5bac","repo":"hyperledger/fabric","slug":"unexpected-chaincode-type-s","errorCode":null,"errorMessage":"unexpected chaincode type: %s","messagePattern":"unexpected chaincode type: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/committer/txvalidator/v14/validator.go","lineNumber":593,"sourceCode":"\t\t\tupgradeIns, err := v.getUpgradeTxInstance(channelID, cis.ChaincodeSpec.Input.Args[2])\n\t\t\tif err != nil {\n\t\t\t\treturn invokeIns, nil, nil\n\t\t\t}\n\t\t\treturn invokeIns, upgradeIns, nil\n\t\t}\n\t}\n\n\treturn invokeIns, nil, nil\n}\n\nfunc (v *TxValidator) getUpgradeTxInstance(channelID string, cdsBytes []byte) (*sysccprovider.ChaincodeInstance, error) {\n\tcds, err := protoutil.UnmarshalChaincodeDeploymentSpec(cdsBytes)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif cds.ChaincodeSpec.Type.String() != \"GOLANG\" {\n\t\treturn nil, errors.Errorf(\"unexpected chaincode type: %s\", cds.ChaincodeSpec.Type.String())\n\t}\n\n\treturn &sysccprovider.ChaincodeInstance{\n\t\tChannelID:        channelID,\n\t\tChaincodeName:    cds.ChaincodeSpec.ChaincodeId.Name,\n\t\tChaincodeVersion: cds.ChaincodeSpec.ChaincodeId.Version,\n\t}, nil\n}\n\ntype dynamicDeserializer struct {\n\tcr ChannelResources\n}\n\nfunc (ds *dynamicDeserializer) DeserializeIdentity(serializedIdentity []byte) (msp.Identity, error) {\n\treturn ds.cr.MSPManager().DeserializeIdentity(serializedIdentity)\n}\n\nfunc (ds *dynamicDeserializer) IsWellFormed(identity *mspprotos.SerializedIdentity) error {","sourceCodeStart":575,"sourceCodeEnd":611,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/committer/txvalidator/v14/validator.go#L575-L611","documentation":"During system chaincode upgrade validation, the deployed chaincode's ChaincodeDeploymentSpec must be a GOLANG spec. Any other chaincode language type is rejected because legacy system chaincode upgrades only support Go chaincode.","triggerScenarios":"getUpgradeTxInstance parses the ChaincodeDeploymentSpec from an upgrade transaction and finds cds.ChaincodeSpec.Type is not GOLANG (e.g., JAVA or NODE).","commonSituations":"Attempting to upgrade a system chaincode with a spec built for a non-Go type; hand-crafted or corrupted upgrade transaction data in a block; tooling that produced a deployment spec with the wrong CCType field.","solutions":["Rebuild the upgrade transaction with a GOLANG ChaincodeSpec type","Verify the tooling/SDK generating the spec sets ChaincodeSpec.Type to GOLANG","If this comes from a block being validated, treat the transaction as invalid and exclude it; do not attempt to commit it","Check whether the upgrade is even required — most system chaincode upgrades are peer-managed, not via transactions"],"exampleFix":"// before\nspec := &pb.ChaincodeSpec{Type: pb.ChaincodeSpec_NODE, ...}\n// after\nspec := &pb.ChaincodeSpec{Type: pb.ChaincodeSpec_GOLANG, ...}","handlingStrategy":"validation","validationCode":"spec, err := protoutil.UnmarshalChaincodeDeploymentSpec(cdsBytes)\nif err != nil { return err }\nif spec.ChaincodeSpec.Type != pb.ChaincodeSpec_GOLANG {\n    return fmt.Errorf(\"upgrade requires GOLANG spec, got %s\", spec.ChaincodeSpec.Type)\n}","typeGuard":"func isGolangSpec(spec *pb.ChaincodeSpec) bool { return spec != nil && spec.Type == pb.ChaincodeSpec_GOLANG }","tryCatchPattern":"inst, err := getUpgradeTxInstance(channelID, cdsBytes)\nif err != nil && strings.Contains(err.Error(), \"unexpected chaincode type\") {\n    // mark transaction invalid; do not process the upgrade\n}","preventionTips":["Always build system chaincode upgrade specs as GOLANG","Validate ChaincodeSpec.Type in tooling before submission","Reject non-Go specs at transaction construction time","Keep upgrade tooling aligned with legacy LSCC requirements"],"tags":["chaincode","system-chaincode","validation"],"backgroundTag":"unexpected-chaincode-type","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"}