{"record":{"id":"c7bcf62ec9609d1e","repo":"hyperledger/fabric","slug":"error-while-reading-bootstrappingsnapshotinfo-file","errorCode":null,"errorMessage":"error while reading bootstrappingSnapshotInfo file","messagePattern":"error while reading bootstrappingSnapshotInfo file","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"common/ledger/blkstorage/blockfile_helper.go","lineNumber":179,"sourceCode":"\treturn strings.HasPrefix(name, blockfilePrefix)\n}\n\nfunc getFileInfoOrPanic(rootDir string, fileNum int) os.FileInfo {\n\tfilePath := deriveBlockfilePath(rootDir, fileNum)\n\tfileInfo, err := os.Lstat(filePath)\n\tif err != nil {\n\t\tpanic(errors.Wrapf(err, \"error retrieving file info for file number %d\", fileNum))\n\t}\n\treturn fileInfo\n}\n\nfunc loadBootstrappingSnapshotInfo(rootDir string) (*BootstrappingSnapshotInfo, error) {\n\tbsiBytes, err := os.ReadFile(filepath.Join(rootDir, bootstrappingSnapshotInfoFile))\n\tif os.IsNotExist(err) {\n\t\treturn nil, nil\n\t}\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"error while reading bootstrappingSnapshotInfo file\")\n\t}\n\tbsi := &BootstrappingSnapshotInfo{}\n\tif err := proto.Unmarshal(bsiBytes, bsi); err != nil {\n\t\treturn nil, errors.Wrapf(err, \"error while unmarshalling bootstrappingSnapshotInfo\")\n\t}\n\treturn bsi, nil\n}\n\nfunc IsBootstrappedFromSnapshot(blockStorageDir, ledgerID string) (bool, error) {\n\tledgerDir := filepath.Join(blockStorageDir, ChainsDir, ledgerID)\n\t_, err := os.Stat(filepath.Join(ledgerDir, bootstrappingSnapshotInfoFile))\n\tif os.IsNotExist(err) {\n\t\treturn false, nil\n\t}\n\tif err != nil {\n\t\treturn false, errors.Wrapf(err, \"failed to read bootstrappingSnapshotInfo file under blockstore directory %s\", ledgerDir)\n\t}\n\treturn true, nil","sourceCodeStart":161,"sourceCodeEnd":197,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/common/ledger/blkstorage/blockfile_helper.go#L161-L197","documentation":"loadBootstrappingSnapshotInfo wraps a non-ENOENT error from os.ReadFile of bootstrappingSnapshotInfoFile in the ledger's block storage dir. Not-exist is treated as 'not bootstrapped from snapshot' and returns nil; any other read error becomes this wrapped error, which newBlockfileMgr panics on.","triggerScenarios":"os.ReadFile fails with a non-NotExist error (permission denied, I/O error, path is a directory) on the bootstrappingSnapshotInfo file during blockfileMgr startup.","commonSituations":"Peer user lacks read permission on a restored ledger dir; corrupted filesystem; the snapshot-info file was replaced with a directory or unreadable file during a partial snapshot restore.","solutions":["Fix read permissions on the ledger dir / bootstrappingSnapshotInfo file (chown/chmod to the peer user)","If the file is corrupted or the snapshot restore was partial, re-restore the ledger from a valid snapshot or reset the ledger","Check filesystem/mount health if the error is an I/O failure"],"exampleFix":"// before: copying snapshot as root leaves root-owned files\n// after:\n// sudo chown -R peer:peer /var/hyperledger/production/ledgersData/chains/<ledgerID>/","handlingStrategy":"try-catch","validationCode":"path := filepath.Join(rootDir, \"bootstrappingSnapshotInfo\")\nif fi, err := os.Stat(path); err == nil && !fi.Mode().IsRegular() {\n    return fmt.Errorf(\"%s is not a regular file\", path)\n}","typeGuard":"func snapshotInfoReadable(rootDir string) bool {\n    f, err := os.Open(filepath.Join(rootDir, \"bootstrappingSnapshotInfo\"))\n    if err != nil { return false }\n    f.Close()\n    return true\n}","tryCatchPattern":"bsi, err := loadBootstrappingSnapshotInfo(rootDir)\nif err != nil {\n    return fmt.Errorf(\"ledger %s unusable, restore snapshot: %w\", ledgerID, err)\n}","preventionTips":["Restore snapshots with the peer user or chown afterwards","Verify snapshot integrity (checksums) before starting the peer","Never hand-edit files under ledgersData"],"tags":["filesystem","snapshot","permissions"],"backgroundTag":"file-read-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"}