hyperledger/fabric · error · VSCCEndorsementPolicyError

Wrong number of arguments for invocation lscc(%s): received

Error message

Wrong number of arguments for invocation lscc(%s): received %d

What it means

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.

Source

Thrown at core/handlers/validation/builtin/v12/validation_logic.go:524

		return policyErr(fmt.Errorf("malformed chaincode invocation spec"))
	}

	lsccFunc := string(cis.ChaincodeSpec.Input.Args[0])
	lsccArgs := cis.ChaincodeSpec.Input.Args[1:]

	logger.Debugf("VSCC info: ValidateLSCCInvocation acting on %s %#v", lsccFunc, lsccArgs)

	switch lsccFunc {
	case lscc.UPGRADE, lscc.DEPLOY:
		logger.Debugf("VSCC info: validating invocation of lscc function %s on arguments %#v", lsccFunc, lsccArgs)

		if len(lsccArgs) < 2 {
			return policyErr(fmt.Errorf("Wrong number of arguments for invocation lscc(%s): expected at least 2, received %d", lsccFunc, len(lsccArgs)))
		}

		if (!ac.PrivateChannelData() && len(lsccArgs) > 5) ||
			(ac.PrivateChannelData() && len(lsccArgs) > 6) {
			return policyErr(fmt.Errorf("Wrong number of arguments for invocation lscc(%s): received %d", lsccFunc, len(lsccArgs)))
		}

		cdsArgs, err := protoutil.UnmarshalChaincodeDeploymentSpec(lsccArgs[1])
		if err != nil {
			return policyErr(fmt.Errorf("GetChaincodeDeploymentSpec error %s", err))
		}

		if cdsArgs == nil || cdsArgs.ChaincodeSpec == nil || cdsArgs.ChaincodeSpec.ChaincodeId == nil ||
			cap.Action == nil || cap.Action.ProposalResponsePayload == nil {
			return policyErr(fmt.Errorf("VSCC error: invocation of lscc(%s) does not have appropriate arguments", lsccFunc))
		}

		switch cdsArgs.ChaincodeSpec.Type.String() {
		case "GOLANG", "NODE", "JAVA", "CAR":
		default:
			return policyErr(fmt.Errorf("unexpected chaincode spec type: %s", cdsArgs.ChaincodeSpec.Type.String()))
		}

View on GitHub (pinned to 2736b63f8f)

Solutions

  1. Remove the extra argument (usually the collections-config bytes) from the lscc invocation, or
  2. Enable the V1_2 (PrivateChannelData) capability on the channel via a channel config update if private data collections are needed.
  3. Align client SDK/CLI version with the channel capability level before building the invoke arguments.
  4. Count the args array before submitting: it must be 2-5 args (no private data capability) or 2-6 args (with it).

Example fix

// before: 6 args on a channel without PrivateChannelData capability
args := [][]byte{[]byte("deploy"), name, cdsBytes, policyBytes, escc, vscc, collConfig}
// after: enable V1_2 capability in channel config, or drop the extra arg
args := [][]byte{[]byte("deploy"), name, cdsBytes, policyBytes, escc, vscc}
Defensive patterns

Strategy: validation

Validate before calling

// maxArgs depends on the channel's PrivateChannelData capability
maxArgs := 5
if channelCapabilities.PrivateChannelData() {
    maxArgs = 6
}
if len(lsccArgs) > maxArgs {
    return fmt.Errorf("lscc deploy/upgrade accepts at most %d args, got %d", maxArgs, len(lsccArgs))
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04). Data as JSON: /api/errors/cc71c2bbfc1ed34d. Report an issue: GitHub.