{"record":{"id":"95deff6f81eefe06","repo":"ipfs/kubo","slug":"some-blocks-not-removed","errorCode":null,"errorMessage":"some blocks not removed","messagePattern":"some blocks not removed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/commands/block.go","lineNumber":357,"sourceCode":"\t\t\tfor {\n\t\t\t\tres, err := res.Next()\n\t\t\t\tif err == io.EOF {\n\t\t\t\t\tbreak\n\t\t\t\t} else if err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tr := res.(*removedBlock)\n\t\t\t\tif r.Hash == \"\" && r.Error != \"\" {\n\t\t\t\t\treturn fmt.Errorf(\"aborted: %s\", r.Error)\n\t\t\t\t} else if r.Error != \"\" {\n\t\t\t\t\tsomeFailed = true\n\t\t\t\t\tfmt.Fprintf(os.Stderr, \"cannot remove %s: %s\\n\", r.Hash, r.Error)\n\t\t\t\t} else {\n\t\t\t\t\tfmt.Fprintf(os.Stdout, \"removed %s\\n\", r.Hash)\n\t\t\t\t}\n\t\t\t}\n\t\t\tif someFailed {\n\t\t\t\treturn fmt.Errorf(\"some blocks not removed\")\n\t\t\t}\n\t\t\treturn nil\n\t\t},\n\t},\n\tType: removedBlock{},\n}\n","sourceCodeStart":339,"sourceCodeEnd":364,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/core/commands/block.go#L339-L364","documentation":"`ipfs block rm` reports this aggregate error when at least one requested block could not be removed. During iteration each per-block failure prints `cannot remove <hash>: <error>` to stderr, sets someFailed=true, and at the end the command returns `some blocks not removed` so scripts see a non-zero exit even though other blocks were removed successfully.","triggerScenarios":"`ipfs block rm <cids...>` where any CID fails removal (e.g. it is pinned, or does not exist without --force, or the datastore errors).","commonSituations":"Attempting to remove pinned blocks (block rm does not unpin), removing nonexistent CIDs, or batch scripts that mix valid and invalid CIDs.","solutions":["Check stderr for the per-block `cannot remove <hash>: <reason>` lines","Unpin blocks first with `ipfs pin rm <cid>` before removing them","Use --force to ignore errors for blocks that don't exist","Re-run with only the CIDs that failed after addressing each specific cause"],"exampleFix":"// before\nipfs block rm QmPinned QmOk\n// after\nipfs pin rm QmPinned\nipfs block rm QmPinned QmOk","handlingStrategy":"validation","validationCode":"// pre-check pins before removal\nfor _, cid := range cids {\n    if err := exec.Command(\"ipfs\", \"pin\", \"ls\", cid).Run(); err == nil {\n        _ = exec.Command(\"ipfs\", \"pin\", \"rm\", cid).Run()\n    }\n}","typeGuard":"null","tryCatchPattern":"if err != nil && err.Error() == \"some blocks not removed\" {\n    // parse stderr lines `cannot remove <hash>: <reason>` and retry survivors\n}","preventionTips":["Unpin blocks before removing them","Use --force for CIDs that may not exist","Parse per-block stderr lines to know which failed","Keep a per-CID error log for batch removals"],"tags":["cli","blockstore","pinning"],"backgroundTag":"partial-operation-failure","analyzedSha":"329838acdfafae224582930457efe80aa217afc0","analyzedAt":"2026-09-03T18:30:52.135Z","contentChangedAt":"2026-09-03T18:30:52.135Z","schemaVersion":2},"datasetVersion":"2026-09-11T00:17:11.886Z"}