ipfs/kubo · error

CheckCIDSize: getting node size: %w

Error message

CheckCIDSize: getting node size: %w

What it means

CheckCIDSize calls n.Size() on the fetched DAG node to obtain its byte size for the block-size check. Size() can fail for nodes whose size cannot be computed (e.g. raw/unsupported node types), and the failure is wrapped with this prefix. The block-size limit check itself then runs in CheckBlockSize.

Source

Thrown at core/commands/cmdutils/utils.go:37

	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-sizes
	if size > SoftBlockLimit {
		return fmt.Errorf("produced block is over 2MiB: big blocks can't be exchanged with other peers. consider using UnixFS for automatic chunking of bigger files, or pass --allow-big-block to override")
	}
	return nil
}

View on GitHub (pinned to 329838acdf)

Solutions

  1. Inspect the wrapped error; unsupported node kinds are the usual cause
  2. Prefer wrapping content in UnixFS so sizes are computable
  3. If the node is raw, use its encoded length or skip the size check via --allow-big-block semantics where appropriate
Defensive patterns

Strategy: validation

Validate before calling

n, err := dagAPI.Get(ctx, c)
if err != nil {
    return err
}
if _, err := n.Size(); err != nil {
    return fmt.Errorf("node size unsupported: %w", err)
}

Try / catch

if err := cmdutils.CheckCIDSize(req, c, dagAPI); err != nil {
    if strings.Contains(err.Error(), "getting node size") {
        // fall back to skipping the size check or use raw block length
    }
    return err
}

Prevention

When it happens

Trigger: dag put / related commands where the fetched node's Size() errors — typically raw or unixfs nodes without length metadata, or a codec whose size computation is unsupported.

Common situations: Putting raw blocks whose size cannot be derived; custom codec nodes; corrupted nodes in the datastore.

Related errors


AI-assisted analysis of ipfs/kubo@329838acdf (2026-09-03). Data as JSON: /api/errors/71d0f913d872013e. Report an issue: GitHub.