{"record":{"id":"f88592ea17d58b81","repo":"hyperledger/fabric","slug":"malformed-chaincode-invocation-spec","errorCode":null,"errorMessage":"malformed chaincode invocation spec","messagePattern":"malformed chaincode invocation spec","errorType":"validation","errorClass":"VSCCEndorsementPolicyError","httpStatus":null,"severity":"error","filePath":"core/handlers/validation/builtin/v12/validation_logic.go","lineNumber":506,"sourceCode":") commonerrors.TxValidationError {\n\tcpp, err := protoutil.UnmarshalChaincodeProposalPayload(cap.ChaincodeProposalPayload)\n\tif err != nil {\n\t\tlogger.Errorf(\"VSCC error: GetChaincodeProposalPayload failed, err %s\", err)\n\t\treturn policyErr(err)\n\t}\n\n\tcis := &pb.ChaincodeInvocationSpec{}\n\terr = proto.Unmarshal(cpp.Input, cis)\n\tif err != nil {\n\t\tlogger.Errorf(\"VSCC error: Unmarshal ChaincodeInvocationSpec failed, err %s\", err)\n\t\treturn policyErr(err)\n\t}\n\n\tif cis.ChaincodeSpec == nil ||\n\t\tcis.ChaincodeSpec.Input == nil ||\n\t\tcis.ChaincodeSpec.Input.Args == nil {\n\t\tlogger.Errorf(\"VSCC error: committing invalid vscc invocation\")\n\t\treturn policyErr(fmt.Errorf(\"malformed chaincode invocation spec\"))\n\t}\n\n\tlsccFunc := string(cis.ChaincodeSpec.Input.Args[0])\n\tlsccArgs := cis.ChaincodeSpec.Input.Args[1:]\n\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)))","sourceCodeStart":488,"sourceCodeEnd":524,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/handlers/validation/builtin/v12/validation_logic.go#L488-L524","documentation":"When a transaction calls lscc, VSCC's ValidateLSCCInvocation re-validates the original proposal payload. This error means the ChaincodeInvocationSpec unmarshaled from the payload has no ChaincodeSpec, no Input, or nil Args — the invocation structure is incomplete, so it cannot be validated. The transaction is rejected as a policy error.","triggerScenarios":"Committing a transaction whose ChaincodeProposalPayload.Input does not unmarshal into a fully-populated ChaincodeInvocationSpec: ChaincodeSpec == nil, ChaincodeSpec.Input == nil, or ChaincodeSpec.Input.Args == nil — e.g. a hand-crafted or truncated proposal envelope.","commonSituations":"Custom client code building envelopes manually with missing fields; SDK misuse where the invoke spec was never populated; tampered or corrupted transactions; testing tools that submit partially-filled ChaincodeInvocationSpec messages.","solutions":["Fix the client to construct a complete ChaincodeInvocationSpec with ChaincodeSpec, Input, and at least one Arg (the lscc function name).","Use the SDK's high-level invoke/chaincode-install APIs instead of manually assembling protobuf envelopes.","Verify the marshaled proposal payload is not truncated or altered between endorsement and commit.","Re-submit the transaction; the rejected tx cannot be repaired post-commit."],"exampleFix":"// before: incomplete spec\ncis := &pb.ChaincodeInvocationSpec{}\n// after: fully populated\ncis := &pb.ChaincodeInvocationSpec{\n  ChaincodeSpec: &pb.ChaincodeSpec{\n    Type: pb.ChaincodeSpec_GOLANG,\n    ChaincodeId: &pb.ChaincodeID{Name: \"lscc\"},\n    Input: &pb.ChaincodeInput{Args: [][]byte{[]byte(\"deploy\"), ccName, ccVersion, cdsBytes}},\n  },\n}","handlingStrategy":"validation","validationCode":"// client-side check before submitting an lscc invocation\nif cis.ChaincodeSpec == nil || cis.ChaincodeSpec.Input == nil || len(cis.ChaincodeSpec.Input.Args) == 0 {\n    return errors.New(\"refusing to submit: ChaincodeInvocationSpec is missing ChaincodeSpec/Input/Args\")\n}","typeGuard":"func isWellFormedInvocationSpec(cis *pb.ChaincodeInvocationSpec) bool {\n    return cis != nil && cis.ChaincodeSpec != nil &&\n        cis.ChaincodeSpec.Input != nil &&\n        cis.ChaincodeSpec.Input.Args != nil && len(cis.ChaincodeSpec.Input.Args) > 0\n}","tryCatchPattern":null,"preventionTips":["Use SDK/CLI APIs to build proposals rather than hand-assembling envelopes.","Validate the populated spec struct before marshaling and submitting.","Never mutate envelope bytes between endorsement and commit."],"tags":["hyperledger-fabric","vscc","lscc","protobuf","transaction-validation"],"backgroundTag":"malformed-payload","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"}