hyperledger/fabric · error

failed listing installed chaincodes

Error message

failed listing installed chaincodes

What it means

NewMetadataManager builds the LSCC metadata manager by first enumerating the chaincodes installed on the peer's filesystem via the supplied Enumerator. If that enumeration fails (e.g. it cannot walk the chaincode install directory), the error is wrapped with 'failed listing installed chaincodes' and no manager is created.

Source

Thrown at core/cclifecycle/lifecycle.go:94

// QueryCreator creates queries
type QueryCreator interface {
	// NewQuery creates a new Query, or error on failure
	NewQuery() (Query, error)
}

// QueryCreatorFunc creates a new query
type QueryCreatorFunc func() (Query, error)

// NewQuery creates a new Query, or error on failure
func (queryCreator QueryCreatorFunc) NewQuery() (Query, error) {
	return queryCreator()
}

// NewMetadataManager creates a metadata manager for lscc chaincodes.
func NewMetadataManager(installedChaincodes Enumerator) (*MetadataManager, error) {
	installedCCs, err := installedChaincodes.Enumerate()
	if err != nil {
		return nil, errors.Wrap(err, "failed listing installed chaincodes")
	}

	return &MetadataManager{
		installedCCs:           installedCCs,
		deployedCCsByChannel:   map[string]*chaincode.MetadataMapping{},
		queryCreatorsByChannel: map[string]QueryCreator{},
	}, nil
}

// Metadata returns the metadata of the chaincode on the given channel,
// or nil if not found or an error occurred at retrieving it
func (m *MetadataManager) Metadata(channel string, cc string, collections ...string) *chaincode.Metadata {
	queryCreator := m.queryCreatorsByChannel[channel]
	if queryCreator == nil {
		Logger.Warning("Requested Metadata for non-existent channel", channel)
		return nil
	}
	// Search the metadata in our local cache, and if it exists - return it, but only if

View on GitHub (pinned to 2736b63f8f)

Solutions

  1. Inspect the wrapped cause to identify the filesystem failure.
  2. Check permissions and existence of the peer's chaincode install directory (fileSystemPath).
  3. Remove or repair corrupt/partial chaincode package files listed in the directory.
  4. Restart the peer after fixing storage (mount/permission) issues; on Kubernetes, verify persistent volume mounts.

Example fix

// before: chaincode dir not writable by peer user
chown -R hyperledger:hyperledger /var/hyperledger/production/chaincodes
// after: correct ownership, then recreate the manager
mgr, err := lifecycle.NewMetadataManager(ccStore)
Defensive patterns

Strategy: try-catch

Validate before calling

// ensure install dir is readable before constructing the manager
if _, err := os.Stat(chaincodeInstallDir); err != nil {
    return fmt.Errorf("chaincode dir unavailable: %w", err)
}

Type guard

func enumeratorHealthy(e lifecycle.Enumerator) bool {
    _, err := e.Enumerate()
    return err == nil
}

Try / catch

mgr, err := lifecycle.NewMetadataManager(installedCCs)
if err != nil {
    if strings.Contains(err.Error(), "failed listing installed chaincodes") {
        // check permissions/corrupt packages, then retry creation
    }
}

Prevention

When it happens

Trigger: Calling NewMetadataManager(installedChaincodes) where installedChaincodes.Enumerate() returns an error — typically because the peer's chaincode install directory is unreadable/missing or a package file is corrupted.

Common situations: Peer filesystem permission problems on /var/hyperledger/production/chaincodes; partially written or corrupt installed chaincode package files after a crash; running the peer with a misconfigured fileSystemPath so the enumerator cannot find the directory.

Related errors


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