{"record":{"id":"ab130aab9c8d1959","repo":"hyperledger/fabric","slug":"cannot-retrieve-package-for-chaincode-ss-error","errorCode":null,"errorMessage":"cannot retrieve package for chaincode %ss, error %s","messagePattern":"cannot retrieve package for chaincode (.+?)s, error (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/common/ccprovider/ccinfocache.go","lineNumber":56,"sourceCode":"\t\tcache:        make(map[string]*ChaincodeData),\n\t\tcacheSupport: cs,\n\t}\n}\n\nfunc (c *ccInfoCacheImpl) GetChaincodeData(ccNameVersion string) (*ChaincodeData, error) {\n\t// c.cache is guaranteed to be non-nil\n\n\tc.RLock()\n\tccdata, in := c.cache[ccNameVersion]\n\tc.RUnlock()\n\n\tif !in {\n\n\t\t// the chaincode data is not in the cache\n\t\t// try to look it up from the file system\n\t\tccpack, err := c.cacheSupport.GetChaincode(ccNameVersion)\n\t\tif err != nil || ccpack == nil {\n\t\t\treturn nil, fmt.Errorf(\"cannot retrieve package for chaincode %ss, error %s\", ccNameVersion, err)\n\t\t}\n\n\t\t// we have a non-nil ChaincodeData, put it in the cache\n\t\tc.Lock()\n\t\tccdata = ccpack.GetChaincodeData()\n\t\tc.cache[ccNameVersion] = ccdata\n\t\tc.Unlock()\n\t}\n\n\treturn ccdata, nil\n}\n","sourceCodeStart":38,"sourceCodeEnd":68,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/common/ccprovider/ccinfocache.go#L38-L68","documentation":"GetChaincodeData looks up a chaincode's ChaincodeData in the CCInfoCache; on a cache miss it fetches the package from the filesystem via cacheSupport.GetChaincode. If that lookup returns an error or a nil package, the cache cannot supply chaincode metadata, so it wraps the underlying error with this message. It signals the chaincode package for the given name:version is missing or unreadable on the peer.","triggerScenarios":"Calling GetChaincodeData (or TestCCInfoCache) for a 'name:version' that was never installed, was deleted from the peer's chaincode install directory, or whose package file fails ccprovider lookup (corrupt file, permissions, wrong install path).","commonSituations":"Peer restarted after chaincode files removed from /var/hyperledger/production/chaincodes; chaincode name/version typo in invoke/instantiate; installing under one user and running the peer under another (permission denied); using the cache against a filesystem backing store that was wiped.","solutions":["Install the chaincode package with 'peer chaincode install' so the name:version package exists on the peer","Verify the package file 'name:version' exists in the peer's chaincode install directory and is readable by the peer process","Check the wrapped error (%s suffix) for the root cause — nil err with missing package usually means the package is simply absent","Correct the chaincode name/version string used by the caller"],"exampleFix":"// before\nccdata, err := ccprovider.GetChaincodeData(\"mycc1.0\") // typo'd name\n// after\nccdata, err := ccprovider.GetChaincodeData(\"mycc:1.0\") // correct name:version","handlingStrategy":"try-catch","validationCode":"// Go: check the package exists before touching the cache\nnameVer := \"mycc:1.0\"\nif _, err := os.Stat(filepath.Join(installDir, nameVer)); os.IsNotExist(err) {\n    return fmt.Errorf(\"chaincode %s not installed on this peer\", nameVer)\n}","typeGuard":"func hasChaincodeData(ccd ccprovider.ChaincodeData) bool { return ccd != nil && ccd.Name != \"\" }","tryCatchPattern":"ccdata, err := ccprovider.GetChaincodeData(\"mycc:1.0\")\nif err != nil {\n    if strings.Contains(err.Error(), \"cannot retrieve package for chaincode\") {\n        // treat as 'not installed': prompt user to install or fail fast\n        return fmt.Errorf(\"chaincode not installed: %w\", err)\n    }\n    return err\n}","preventionTips":["Always run 'peer chaincode install' on every peer before invoking","Keep name:version strings centralized to avoid typos","Verify install directory ownership matches the peer process user","Log the wrapped cause (%s) to distinguish missing vs unreadable packages"],"tags":["hyperledger-fabric","chaincode","cache","filesystem"],"backgroundTag":"chaincode-package-not-found","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"}