{"record":{"id":"e12ced0a12710ae0","repo":"ipfs/kubo","slug":"checkcidsize-getting-dag-w","errorCode":null,"errorMessage":"CheckCIDSize: getting dag: %w","messagePattern":"CheckCIDSize: getting dag: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/commands/cmdutils/utils.go","lineNumber":32,"sourceCode":"\nconst (\n\tAllowBigBlockOptionName = \"allow-big-block\"\n\t// SoftBlockLimit is the maximum block size for bitswap transfer.\n\t// If this value changes, update the \"2MiB\" strings in error messages below.\n\tSoftBlockLimit  = 2 * 1024 * 1024 // https://specs.ipfs.tech/bitswap-protocol/#block-sizes\n\tMaxPinNameBytes = 255             // Maximum number of bytes allowed for a pin name\n)\n\nvar AllowBigBlockOption cmds.Option\n\nfunc init() {\n\tAllowBigBlockOption = 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)\n}\n\nfunc CheckCIDSize(req *cmds.Request, c cid.Cid, dagAPI coreiface.APIDagService) error {\n\tn, err := dagAPI.Get(req.Context, c)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"CheckCIDSize: getting dag: %w\", err)\n\t}\n\n\tnodeSize, err := n.Size()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"CheckCIDSize: getting node size: %w\", err)\n\t}\n\n\treturn CheckBlockSize(req, nodeSize)\n}\n\nfunc CheckBlockSize(req *cmds.Request, size uint64) error {\n\tallowAnyBlockSize, _ := req.Options[AllowBigBlockOptionName].(bool)\n\tif allowAnyBlockSize {\n\t\treturn nil\n\t}\n\n\t// Block size is limited to SoftBlockLimit (2MiB) as defined in the bitswap spec.\n\t// https://specs.ipfs.tech/bitswap-protocol/#block-sizes","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/core/commands/cmdutils/utils.go#L14-L50","documentation":"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.","triggerScenarios":"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.","commonSituations":"`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.","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"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// ensure block is present before size check\n_, err := dagAPI.Get(ctx, c)\nif err != nil {\n    return fmt.Errorf(\"block unavailable, aborting size check: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := cmdutils.CheckCIDSize(req, c, dagAPI); err != nil {\n    if errors.Is(err, context.Canceled) || isNotFound(err) {\n        return err // non-retryable\n    }\n    // transient: retry with backoff\n}","preventionTips":["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"],"tags":["dag","blockstore","cid"],"backgroundTag":"dag-get-failed","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"}