{"record":{"id":"3db18fa3fff032ca","repo":"hyperledger/fabric","slug":"getchaincodedeploymentspec-error-s","errorCode":null,"errorMessage":"GetChaincodeDeploymentSpec error %s","messagePattern":"GetChaincodeDeploymentSpec error (.+?)","errorType":"validation","errorClass":"VSCCEndorsementPolicyError","httpStatus":null,"severity":"error","filePath":"core/handlers/validation/builtin/v12/validation_logic.go","lineNumber":529,"sourceCode":"\n\tlogger.Debugf(\"VSCC info: ValidateLSCCInvocation acting on %s %#v\", lsccFunc, lsccArgs)\n\n\tswitch lsccFunc {\n\tcase lscc.UPGRADE, lscc.DEPLOY:\n\t\tlogger.Debugf(\"VSCC info: validating invocation of lscc function %s on arguments %#v\", lsccFunc, lsccArgs)\n\n\t\tif len(lsccArgs) < 2 {\n\t\t\treturn policyErr(fmt.Errorf(\"Wrong number of arguments for invocation lscc(%s): expected at least 2, received %d\", lsccFunc, len(lsccArgs)))\n\t\t}\n\n\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))","sourceCodeStart":511,"sourceCodeEnd":547,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/handlers/validation/builtin/v12/validation_logic.go#L511-L547","documentation":"VSCC's ValidateLSCCInvocation wraps the error from protoutil.UnmarshalChaincodeDeploymentSpec when parsing the second argument of an lscc transaction. The chaincode deployment spec bytes supplied in the LSCC invocation could not be deserialized into a pb.ChaincodeDeploymentSpec, so validation fails with a policy error (the transaction is marked invalid).","triggerScenarios":"A transaction invoking lscc (deploy/upgrade) carries lsccArgs[1] that is not a valid serialized ChaincodeDeploymentSpec proto: empty bytes, truncated buffer, corrupted payload, or bytes produced by a non-protobuf encoder.","commonSituations":"Hand-crafted deploy transactions (SDK or CLI misuse), payloads mangled by an intermediary or proxy, Fabric SDK/proto version mismatch producing an incompatible serialization, or fuzzed/malicious transactions rejected during block validation.","solutions":["Verify the transaction's second lscc argument is created via proto marshaling of ChaincodeDeploymentSpec (e.g. utils.Marshal or protoutil), not JSON or raw bytes.","Check SDK and peer Fabric versions align (v1.x proto definitions) and regenerate the payload with a matching protobuf runtime.","Re-inspect the original proposal payload for corruption/truncation in transit; re-submit the deploy transaction."],"exampleFix":"// before: passing a JSON-marshaled spec\nargs[1], _ := json.Marshal(deploySpec)\n// after: proto-marshal the deployment spec\nargs[1], err := protoutil.Marshal(deploySpec)\nif err != nil { return err }","handlingStrategy":"validation","validationCode":"// client-side pre-check before submitting the lscc tx\nspecBytes := args[1]\nvar cds pb.ChaincodeDeploymentSpec\nif len(specBytes) == 0 || proto.Unmarshal(specBytes, &cds) != nil || cds.ChaincodeSpec == nil {\n    return errors.New(\"lscc arg[1] is not a valid ChaincodeDeploymentSpec\")\n}","typeGuard":"func isValidCDSEntry(b []byte) bool {\n    var cds pb.ChaincodeDeploymentSpec\n    return len(b) > 0 && proto.Unmarshal(b, &cds) == nil && cds.ChaincodeSpec != nil\n}","tryCatchPattern":"spec, err := protoutil.UnmarshalChaincodeDeploymentSpec(args[1])\nif err != nil {\n    logger.Warnf(\"malformed deployment spec, tx will be invalid: %v\", err)\n    return err\n}","preventionTips":["Always proto-marshal the ChaincodeDeploymentSpec (never JSON or manual byte packing).","Add a local unmarshal dry-run in deploy scripts before submitting.","Keep client protobuf definitions in sync with the peer's Fabric version."],"tags":["fabric","vscc","lscc","protobuf","validation"],"backgroundTag":"protobuf-unmarshal-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"}