{"record":{"id":"3d1396baa21a3891","repo":"hyperledger/fabric","slug":"unexpected-chaincode-spec-type-s","errorCode":null,"errorMessage":"unexpected chaincode spec type: %s","messagePattern":"unexpected chaincode spec type: (.+?)","errorType":"validation","errorClass":"VSCCEndorsementPolicyError","httpStatus":null,"severity":"error","filePath":"core/handlers/validation/builtin/v12/validation_logic.go","lineNumber":540,"sourceCode":"\t\tif (!ac.PrivateChannelData() && len(lsccArgs) > 5) ||\n\t\t\t(ac.PrivateChannelData() && len(lsccArgs) > 6) {\n\t\t\treturn policyErr(fmt.Errorf(\"Wrong number of arguments for invocation lscc(%s): received %d\", lsccFunc, len(lsccArgs)))\n\t\t}\n\n\t\tcdsArgs, err := protoutil.UnmarshalChaincodeDeploymentSpec(lsccArgs[1])\n\t\tif err != nil {\n\t\t\treturn policyErr(fmt.Errorf(\"GetChaincodeDeploymentSpec error %s\", err))\n\t\t}\n\n\t\tif cdsArgs == nil || cdsArgs.ChaincodeSpec == nil || cdsArgs.ChaincodeSpec.ChaincodeId == nil ||\n\t\t\tcap.Action == nil || cap.Action.ProposalResponsePayload == nil {\n\t\t\treturn policyErr(fmt.Errorf(\"VSCC error: invocation of lscc(%s) does not have appropriate arguments\", lsccFunc))\n\t\t}\n\n\t\tswitch cdsArgs.ChaincodeSpec.Type.String() {\n\t\tcase \"GOLANG\", \"NODE\", \"JAVA\", \"CAR\":\n\t\tdefault:\n\t\t\treturn policyErr(fmt.Errorf(\"unexpected chaincode spec type: %s\", cdsArgs.ChaincodeSpec.Type.String()))\n\t\t}\n\n\t\t// validate chaincode name\n\t\tccName := cdsArgs.ChaincodeSpec.ChaincodeId.Name\n\t\t// it must comply with the lscc.ChaincodeNameRegExp\n\t\tif !lscc.ChaincodeNameRegExp.MatchString(ccName) {\n\t\t\treturn policyErr(errors.Errorf(\"invalid chaincode name '%s'\", ccName))\n\t\t}\n\t\t// it can't match the name of one of the system chaincodes\n\t\tif _, in := systemChaincodeNames[ccName]; in {\n\t\t\treturn policyErr(errors.Errorf(\"chaincode name '%s' is reserved for system chaincodes\", ccName))\n\t\t}\n\n\t\t// validate chaincode version\n\t\tccVersion := cdsArgs.ChaincodeSpec.ChaincodeId.Version\n\t\t// it must comply with the lscc.ChaincodeVersionRegExp\n\t\tif !lscc.ChaincodeVersionRegExp.MatchString(ccVersion) {\n\t\t\treturn policyErr(errors.Errorf(\"invalid chaincode version '%s'\", ccVersion))","sourceCodeStart":522,"sourceCodeEnd":558,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/handlers/validation/builtin/v12/validation_logic.go#L522-L558","documentation":"VSCC validates that the ChaincodeSpec.Type of the lscc deployment spec is one of GOLANG, NODE, JAVA, or CAR. Any other chaincode language type (or an unset type) in a deploy/upgrade transaction is rejected with this policy error.","triggerScenarios":"A deploy/upgrade transaction whose ChaincodeDeploymentSpec.ChaincodeSpec.Type serializes to a type outside {GOLANG, NODE, JAVA, CAR} — e.g. UNSPECIFIED type, or a newer chaincode type unknown to this peer version.","commonSituations":"SDK defaulting the type incorrectly, a peer on an older Fabric version validating transactions containing a newer chaincode type, or hand-constructed ChaincodeSpec messages with the Type field left unset (UNSPECIFIED).","solutions":["Set ChaincodeSpec.Type explicitly to GOLANG, NODE, JAVA, or CAR when constructing the ChaincodeDeploymentSpec.","Align peer and SDK Fabric versions so the type value is one this peer's VSCC recognizes.","If using a custom type, port the chaincode to a supported language before deploy."],"exampleFix":"// before\nspec := &pb.ChaincodeSpec{} // Type left unset -> UNSPECIFIED\n// after\nspec := &pb.ChaincodeSpec{Type: pb.ChaincodeSpec_GOLANG, ChaincodeId: ccid, Input: input}","handlingStrategy":"validation","validationCode":"t := cds.ChaincodeSpec.Type.String()\nif t != \"GOLANG\" && t != \"NODE\" && t != \"JAVA\" && t != \"CAR\" {\n    return fmt.Errorf(\"unsupported chaincode type %q\", t)\n}","typeGuard":"func isSupportedCCType(t pb.ChaincodeSpec_Type) bool {\n    switch t {\n    case pb.ChaincodeSpec_GOLANG, pb.ChaincodeSpec_NODE, pb.ChaincodeSpec_JAVA, pb.ChaincodeSpec_CAR:\n        return true\n    }\n    return false\n}","tryCatchPattern":"if !isSupportedCCType(spec.Type) {\n    return fmt.Errorf(\"chaincode type %s not supported by this peer\", spec.Type)\n}","preventionTips":["Explicitly set ChaincodeSpec.Type; never rely on the UNSPECIFIED default.","Check peer Fabric version support before deploying with newer chaincode types.","Validate the type in CI before submitting deploy transactions."],"tags":["fabric","vscc","lscc","chaincode-type","validation"],"backgroundTag":"unsupported-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"}