ipfs/kubo · error
CheckCIDSize: getting dag: %w
Error message
CheckCIDSize: getting dag: %w
What it means
CheckCIDSize fetches the DAG node for a CID via dagAPI.Get before enforcing the 2MiB block-size limit. If fetching the node fails (block not found, datastore error, context cancel), the cause is wrapped with this prefix. It is a wrapping error: the real reason is the wrapped err.
Source
Thrown at core/commands/cmdutils/utils.go:32
const (
AllowBigBlockOptionName = "allow-big-block"
// SoftBlockLimit is the maximum block size for bitswap transfer.
// If this value changes, update the "2MiB" strings in error messages below.
SoftBlockLimit = 2 * 1024 * 1024 // https://specs.ipfs.tech/bitswap-protocol/#block-sizes
MaxPinNameBytes = 255 // Maximum number of bytes allowed for a pin name
)
var AllowBigBlockOption cmds.Option
func init() {
AllowBigBlockOption = cmds.BoolOption(AllowBigBlockOptionName, "Disable block size check and allow creation of blocks bigger than 2MiB. WARNING: such blocks won't be transferable over the standard bitswap.").WithDefault(false)
}
func CheckCIDSize(req *cmds.Request, c cid.Cid, dagAPI coreiface.APIDagService) error {
n, err := dagAPI.Get(req.Context, c)
if err != nil {
return fmt.Errorf("CheckCIDSize: getting dag: %w", err)
}
nodeSize, err := n.Size()
if err != nil {
return fmt.Errorf("CheckCIDSize: getting node size: %w", err)
}
return CheckBlockSize(req, nodeSize)
}
func CheckBlockSize(req *cmds.Request, size uint64) error {
allowAnyBlockSize, _ := req.Options[AllowBigBlockOptionName].(bool)
if allowAnyBlockSize {
return nil
}
// Block size is limited to SoftBlockLimit (2MiB) as defined in the bitswap spec.
// https://specs.ipfs.tech/bitswap-protocol/#block-sizesView on GitHub (pinned to 329838acdf)
Solutions
- Inspect the wrapped error for the real cause (not found, timeout, context cancelled)
- Ensure the block exists locally or the node can fetch it (routing/peers online)
- Verify the CID is valid for the configured codec/resolver
- Retry if the failure was a transient network/context issue
Defensive patterns
Strategy: retry
Validate before calling
// ensure block is present before size check
_, err := dagAPI.Get(ctx, c)
if err != nil {
return fmt.Errorf("block unavailable, aborting size check: %w", err)
} Try / catch
if err := cmdutils.CheckCIDSize(req, c, dagAPI); err != nil {
if errors.Is(err, context.Canceled) || isNotFound(err) {
return err // non-retryable
}
// transient: retry with backoff
} Prevention
- Keep the node connected to routing/peers so blocks resolve
- Check context cancellation before long DAG operations
- Validate CIDs before passing to dag put flows
When it happens
Trigger: Calling dag put/export paths that call CheckCIDSize with a CID that is not in the local store, a malformed/unresolvable CID, cancelled request context, or a failing blockservice/datastore.
Common situations: `ipfs dag put` with --allow-of-big-block logic on a CID that hasn't been fetched; operations on offloaded blocks when the daemon is offline; context cancelled mid-request.
Related errors
- CheckCIDSize: getting node size: %w
- dagStore: key was not a cid: %w
- dagStore: key was not a cid: had %d bytes leftover
- checking if new root exists: %w
- new root %s does not exist locally; fetch it first with 'ipf
AI-assisted analysis of ipfs/kubo@329838acdf (2026-09-03).
Data as JSON: /api/errors/e12ced0a12710ae0.
Report an issue: GitHub.