hyperledger/fabric · error

Invalid passed MSP. It must be different from nil.

Error message

Invalid passed MSP. It must be different from nil.

What it means

Returned by msp/cache.New when the wrapped MSP argument is nil. The caching decorator has nothing to cache in front of, so it refuses construction — callers must pass an already-initialized MSP instance.

Source

Thrown at msp/cache/cache.go:27

import (
	"github.com/hyperledger/fabric-lib-go/common/flogging"
	pmsp "github.com/hyperledger/fabric-protos-go-apiv2/msp"
	"github.com/hyperledger/fabric/msp"
	"github.com/pkg/errors"
)

const (
	deserializeIdentityCacheSize = 100
	validateIdentityCacheSize    = 100
	satisfiesPrincipalCacheSize  = 100
)

var mspLogger = flogging.MustGetLogger("msp")

func New(o msp.MSP) (msp.MSP, error) {
	mspLogger.Debugf("Creating Cache-MSP instance")
	if o == nil {
		return nil, errors.Errorf("Invalid passed MSP. It must be different from nil.")
	}

	theMsp := &cachedMSP{MSP: o}
	theMsp.deserializeIdentityCache = newSecondChanceCache(deserializeIdentityCacheSize)
	theMsp.satisfiesPrincipalCache = newSecondChanceCache(satisfiesPrincipalCacheSize)
	theMsp.validateIdentityCache = newSecondChanceCache(validateIdentityCacheSize)

	return theMsp, nil
}

type cachedMSP struct {
	msp.MSP

	// cache for DeserializeIdentity.
	deserializeIdentityCache *secondChanceCache

	// cache for validateIdentity
	validateIdentityCache *secondChanceCache

View on GitHub (pinned to 2736b63f8f)

Solutions

  1. Pass an initialized msp.MSP instance (e.g., from factory New) to New
  2. Fix the caller that constructs the cache before the underlying MSP exists
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at msp/cache/cache.go:27 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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