hyperledger/fabric · error

[channel %s] failed to get chaincode container info for %s

Error message

[channel %s] failed to get chaincode container info for %s

What it means

CheckInvocation calls cs.Lifecycle.ChaincodeEndorsementInfo(channel, chaincodeName, TXSimulator) to resolve the chaincode definition for the namespace; any failure is wrapped as '[channel %s] failed to get chaincode container info for %s'. This means the chaincode (namespace) could not be resolved as defined/committed on that channel — the peer cannot route the invocation. In dev mode the underlying error is also surfaced via logDevModeError hints.

Source

Thrown at core/chaincode/chaincode_support.go:228

	h, err := cs.Launch(ccid)
	if err != nil {
		return nil, err
	}

	return cs.execute(cctype, txParams, chaincodeName, input, h)
}

// CheckInvocation inspects the parameters of an invocation and determines if, how, and to where a that invocation should be routed.
// First, we ensure that the target namespace is defined on the channel and invokable on this peer, according to the lifecycle implementation.
// Then, if the chaincode definition requires it, this function enforces 'init exactly once' semantics.
// Finally, it returns the chaincode ID to route to and the message type of the request (normal transaction, or init).
func (cs *ChaincodeSupport) CheckInvocation(txParams *ccprovider.TransactionParams, chaincodeName string, input *pb.ChaincodeInput) (ccid string, cctype pb.ChaincodeMessage_Type, err error) {
	chaincodeLogger.Debugf("[%s] getting chaincode data for %s on channel %s", shorttxid(txParams.TxID), chaincodeName, txParams.ChannelID)
	cii, err := cs.Lifecycle.ChaincodeEndorsementInfo(txParams.ChannelID, chaincodeName, txParams.TXSimulator)
	if err != nil {
		logDevModeError(cs.UserRunsCC)
		return "", 0, errors.Wrapf(err, "[channel %s] failed to get chaincode container info for %s", txParams.ChannelID, chaincodeName)
	}

	needsInitialization := false
	if cii.EnforceInit {

		value, err := txParams.TXSimulator.GetState(chaincodeName, InitializedKeyName)
		if err != nil {
			return "", 0, errors.WithMessage(err, "could not get 'initialized' key")
		}

		needsInitialization = !bytes.Equal(value, []byte(cii.Version))
	}

	// Note, IsInit is a new field for v2.0 and should only be set for invocations of non-legacy chaincodes.
	// Any invocation of a legacy chaincode with IsInit set will fail.  This is desirable, as the old
	// InstantiationPolicy contract enforces which users may call init.
	if input.IsInit {
		if !cii.EnforceInit {

View on GitHub (pinned to 2736b63f8f)

Solutions

  1. Run 'peer lifecycle chaincode querycommitted -C <channel>' (or 'peer chaincode list --installed') and confirm the namespace exists on that channel.
  2. Correct the chaincode name/channel name in the client request (v2 lifecycle uses the bare name, not name:version).
  3. If not committed, complete the lifecycle: package -> install -> approveformyorg -> checkcommitreadiness -> commit.
  4. Verify the peer has joined the channel ('peer channel list') and fetch the latest channel config/block.
  5. Inspect the wrapped cause in the error message — it names the exact lifecycle failure (e.g. 'cannot get package for chaincode').

Example fix

// before: v2 peer with legacy-style target
targets := []string{"peer0.org1"}
req := channel.Request{ChaincodeID: "mycc:1.0", Fcn: "invoke", Args: ...}
// after: use bare namespace committed on the channel
req := channel.Request{ChaincodeID: "mycc", Fcn: "invoke", Args: ...}
Defensive patterns

Strategy: validation

Validate before calling

// before invoking, confirm the namespace is committed on the channel
out, err := exec.Command("peer", "lifecycle", "chaincode", "querycommitted",
    "-C", channelName).Output()
if err != nil {
    return err
}
if !strings.Contains(string(out), "Name: "+chaincodeName) {
    return fmt.Errorf("chaincode %q is not committed on channel %q", chaincodeName, channelName)
}

Type guard

func isNamespaceResolutionFailure(err error) (channel, ccName string, ok bool) {
    if err == nil {
        return "", "", false
    }
    var m = regexp.MustCompile(`\[channel (.+?)\] failed to get chaincode container info for (.+?)\b`).FindStringSubmatch(err.Error())
    if m == nil {
        return "", "", false
    }
    return m[1], m[2], true
}

Prevention

When it happens

Trigger: Invoking a chaincode name that is not defined/committed on the channel (via ChaincodeSupport.Invoke -> CheckInvocation); querying a channel the peer is not a member of; lifecycle data unreadable; legacy lscc lookups failing when the chaincode was never installed/approved/committed.

Common situations: Typo in chaincode name or channel name; chaincode committed on another channel; peer not joined to the channel; chaincode approved but not committed (v2.x lifecycle); package not installed on this peer; using 'mycc:1.0' name+version syntax on a v2 lifecycle peer that expects bare namespace names.

Related errors


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