{"record":{"id":"cc71c2bbfc1ed34d","repo":"hyperledger/fabric","slug":"wrong-number-of-arguments-for-invocation-lscc-s-cc71c2","errorCode":null,"errorMessage":"Wrong number of arguments for invocation lscc(%s): received %d","messagePattern":"Wrong number of arguments for invocation lscc\\((.+?)\\): received (.+?)","errorType":"validation","errorClass":"VSCCEndorsementPolicyError","httpStatus":null,"severity":"error","filePath":"core/handlers/validation/builtin/v12/validation_logic.go","lineNumber":524,"sourceCode":"\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)))\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","sourceCodeStart":506,"sourceCodeEnd":542,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/handlers/validation/builtin/v12/validation_logic.go#L506-L542","documentation":"For lscc DEPLOY/UPGRADE, VSCC enforces a maximum argument count: at most 5 arguments when the PrivateChannelData capability is disabled, or 6 when enabled. This error is returned when too many arguments were supplied, rejecting the transaction as a policy violation. It complements the minimum-arity check at line 519.","triggerScenarios":"Invoking lscc deploy/upgrade with 6+ arguments on a channel without the PrivateChannelData (V1_2) capability, or 7+ arguments even with it enabled — typically by appending an extra collections-config or endorsement-policy argument the channel does not support.","commonSituations":"Passing a collections-config argument on a channel whose channel group has not enabled V1_2Validation/PrivateChannelData capabilities; leftover extra args from copying deploy scripts between channels with different capability levels; mixing fabric v1.1 clients with v1.2 channels or vice versa.","solutions":["Remove the extra argument (usually the collections-config bytes) from the lscc invocation, or","Enable the V1_2 (PrivateChannelData) capability on the channel via a channel config update if private data collections are needed.","Align client SDK/CLI version with the channel capability level before building the invoke arguments.","Count the args array before submitting: it must be 2-5 args (no private data capability) or 2-6 args (with it)."],"exampleFix":"// before: 6 args on a channel without PrivateChannelData capability\nargs := [][]byte{[]byte(\"deploy\"), name, cdsBytes, policyBytes, escc, vscc, collConfig}\n// after: enable V1_2 capability in channel config, or drop the extra arg\nargs := [][]byte{[]byte(\"deploy\"), name, cdsBytes, policyBytes, escc, vscc}","handlingStrategy":"validation","validationCode":"// maxArgs depends on the channel's PrivateChannelData capability\nmaxArgs := 5\nif channelCapabilities.PrivateChannelData() {\n    maxArgs = 6\n}\nif len(lsccArgs) > maxArgs {\n    return fmt.Errorf(\"lscc deploy/upgrade accepts at most %d args, got %d\", maxArgs, len(lsccArgs))\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check the channel capability (PrivateChannelData/V1_2) before appending a collections-config argument.","Keep deploy/upgrade scripts per-channel so capability differences are explicit.","Count args (2-5, or 2-6 with private data) before every submission.","Update channel capabilities deliberately via config update, not by sending extra args."],"tags":["hyperledger-fabric","vscc","lscc","capabilities","argument-validation"],"backgroundTag":"wrong-argument-count","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"}