{"record":{"id":"953c7d9e90f0e86d","repo":"hyperledger/fabric","slug":"failed-listing-installed-chaincodes","errorCode":null,"errorMessage":"failed listing installed chaincodes","messagePattern":"failed listing installed chaincodes","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/cclifecycle/lifecycle.go","lineNumber":94,"sourceCode":"// QueryCreator creates queries\ntype QueryCreator interface {\n\t// NewQuery creates a new Query, or error on failure\n\tNewQuery() (Query, error)\n}\n\n// QueryCreatorFunc creates a new query\ntype QueryCreatorFunc func() (Query, error)\n\n// NewQuery creates a new Query, or error on failure\nfunc (queryCreator QueryCreatorFunc) NewQuery() (Query, error) {\n\treturn queryCreator()\n}\n\n// NewMetadataManager creates a metadata manager for lscc chaincodes.\nfunc NewMetadataManager(installedChaincodes Enumerator) (*MetadataManager, error) {\n\tinstalledCCs, err := installedChaincodes.Enumerate()\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed listing installed chaincodes\")\n\t}\n\n\treturn &MetadataManager{\n\t\tinstalledCCs:           installedCCs,\n\t\tdeployedCCsByChannel:   map[string]*chaincode.MetadataMapping{},\n\t\tqueryCreatorsByChannel: map[string]QueryCreator{},\n\t}, nil\n}\n\n// Metadata returns the metadata of the chaincode on the given channel,\n// or nil if not found or an error occurred at retrieving it\nfunc (m *MetadataManager) Metadata(channel string, cc string, collections ...string) *chaincode.Metadata {\n\tqueryCreator := m.queryCreatorsByChannel[channel]\n\tif queryCreator == nil {\n\t\tLogger.Warning(\"Requested Metadata for non-existent channel\", channel)\n\t\treturn nil\n\t}\n\t// Search the metadata in our local cache, and if it exists - return it, but only if","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/cclifecycle/lifecycle.go#L76-L112","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Inspect the wrapped cause to identify the filesystem failure.","Check permissions and existence of the peer's chaincode install directory (fileSystemPath).","Remove or repair corrupt/partial chaincode package files listed in the directory.","Restart the peer after fixing storage (mount/permission) issues; on Kubernetes, verify persistent volume mounts."],"exampleFix":"// before: chaincode dir not writable by peer user\nchown -R hyperledger:hyperledger /var/hyperledger/production/chaincodes\n// after: correct ownership, then recreate the manager\nmgr, err := lifecycle.NewMetadataManager(ccStore)","handlingStrategy":"try-catch","validationCode":"// ensure install dir is readable before constructing the manager\nif _, err := os.Stat(chaincodeInstallDir); err != nil {\n    return fmt.Errorf(\"chaincode dir unavailable: %w\", err)\n}","typeGuard":"func enumeratorHealthy(e lifecycle.Enumerator) bool {\n    _, err := e.Enumerate()\n    return err == nil\n}","tryCatchPattern":"mgr, err := lifecycle.NewMetadataManager(installedCCs)\nif err != nil {\n    if strings.Contains(err.Error(), \"failed listing installed chaincodes\") {\n        // check permissions/corrupt packages, then retry creation\n    }\n}","preventionTips":["Run the peer as a user with read/write on the chaincode install directory","Verify persistent volume mounts in containerized deployments","Clean up partial package files after crashes before restarting the peer"],"tags":["hyperledger-fabric","lifecycle","filesystem","chaincode-install"],"backgroundTag":"chaincode-enumeration-failed","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"}