{"record":{"id":"31f7b1ffede35dfd","repo":"hyperledger/fabric","slug":"wrong-number-of-arguments-for-invocation-lscc-s","errorCode":null,"errorMessage":"Wrong number of arguments for invocation lscc(%s): expected at least 2, received %d","messagePattern":"Wrong number of arguments for invocation lscc\\((.+?)\\): expected at least 2, received (.+?)","errorType":"validation","errorClass":"VSCCEndorsementPolicyError","httpStatus":null,"severity":"error","filePath":"core/handlers/validation/builtin/v12/validation_logic.go","lineNumber":519,"sourceCode":"\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)))\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() {","sourceCodeStart":501,"sourceCodeEnd":537,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/handlers/validation/builtin/v12/validation_logic.go#L501-L537","documentation":"For lscc DEPLOY or UPGRADE invocations, VSCC requires at least two arguments after the function name (typically the chaincode name and the ChaincodeDeploymentSpec). This error is returned when len(lsccArgs) < 2, i.e. the invoke supplied fewer arguments than the minimum, so validation cannot proceed and the transaction fails policy.","triggerScenarios":"Invoking lscc deploy/upgrade with only 0 or 1 arguments after the function name — e.g. missing the ChaincodeDeploymentSpec argument, or building the args array incorrectly so the spec ends up in the wrong position.","commonSituations":"Client SDK code assembling deploy/upgrade args by hand and dropping the deployment spec; automated scripts invoking lscc directly with the wrong arity; upgrading Fabric and changing call layout without updating the client.","solutions":["Supply at least 2 arguments after the function name: the chaincode name and a marshaled ChaincodeDeploymentSpec.","Prefer the CLI ('peer chaincode install/instantiate/upgrade') or SDK lifecycle APIs which build the correct argument list.","Dump the args array length before invoking to confirm arity matches the expected layout (2-5 args, or up to 6 with private channel data).","Re-submit a corrected transaction after the failed one is marked invalid."],"exampleFix":"// before: missing the deployment spec argument\nargs := [][]byte{[]byte(\"deploy\"), []byte(\"mycc\")}\n// after: include name + ChaincodeDeploymentSpec\nargs := [][]byte{[]byte(\"deploy\"), []byte(\"mycc\"), cdsBytes}","handlingStrategy":"validation","validationCode":"// lsccFunc args: everything after the function name\nif len(lsccArgs) < 2 {\n    return errors.New(\"lscc deploy/upgrade requires at least 2 args: chaincode name and ChaincodeDeploymentSpec\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Build lscc invocations through peer CLI or SDK helpers that enforce arity.","Assert args length >= 2 before marshal/submit.","Keep the ChaincodeDeploymentSpec at index 1 of the args array."],"tags":["hyperledger-fabric","vscc","lscc","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"}