{"record":{"id":"fdb4e2a111f50da2","repo":"ipfs/kubo","slug":"pin-name-is-d-bytes-max-d-bytes","errorCode":null,"errorMessage":"pin name is %d bytes (max %d bytes)","messagePattern":"pin name is (.+?) bytes \\(max (.+?) bytes\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/commands/cmdutils/utils.go","lineNumber":67,"sourceCode":"\t// Block size is limited to SoftBlockLimit (2MiB) as defined in the bitswap spec.\n\t// https://specs.ipfs.tech/bitswap-protocol/#block-sizes\n\tif size > SoftBlockLimit {\n\t\treturn 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\")\n\t}\n\treturn nil\n}\n\n// ValidatePinName validates that a pin name does not exceed the maximum allowed byte length.\n// Returns an error if the name exceeds MaxPinNameBytes (255 bytes).\nfunc ValidatePinName(name string) error {\n\tif name == \"\" {\n\t\t// Empty names are allowed\n\t\treturn nil\n\t}\n\n\tnameBytes := len([]byte(name))\n\tif nameBytes > MaxPinNameBytes {\n\t\treturn fmt.Errorf(\"pin name is %d bytes (max %d bytes)\", nameBytes, MaxPinNameBytes)\n\t}\n\treturn nil\n}\n\n// PathOrCidPath returns a path.Path built from the argument. It accepts a\n// content path (/ipfs/cid), a native IPFS URI (ipfs://cid, ipns://name, and the\n// schemeless ipfs:cid / ipns:name forms), or a bare CID string.\nfunc PathOrCidPath(str string) (path.Path, error) {\n\tp, err := path.NewPathFromURI(str)\n\tif err == nil {\n\t\treturn p, nil\n\t}\n\n\t// Save the original error before attempting fallback\n\toriginalErr := err\n\n\tif p, err := path.NewPath(\"/ipfs/\" + str); err == nil {\n\t\treturn p, nil","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/core/commands/cmdutils/utils.go#L49-L85","documentation":"ValidatePinName enforces the remote pinning API's maximum pin-name length of MaxPinNameBytes (255 bytes), measured in bytes, not characters. Names longer than the limit are rejected because remote pin services (per the Pinning Services API) would fail to accept them. Empty names are allowed.","triggerScenarios":"`ipfs pin remote add --name=<long-name>` or lsRemote filtering with a name over 255 bytes; non-ASCII names that exceed 255 bytes even with few characters (multibyte runes count fully).","commonSituations":"Auto-generated pin names embedding long paths/URLs; CJK or emoji names where 100+ characters exceed 255 bytes; CI pipelines naming pins with full artifact paths.","solutions":["Shorten the pin name to 255 bytes or fewer","Hash/abbreviate long identifiers (e.g. use a truncated CID or checksum) in generated names","For multibyte names, count bytes (utf8.RuneCountInString is not enough) before submitting"],"exampleFix":"// before\nname := \"pin:\" + strings.Repeat(\"ä\", 300)\n// after\nif len([]byte(name)) > 255 {\n    name = name[:200] // or truncate on a rune boundary to stay <= 255 bytes\n}","handlingStrategy":"validation","validationCode":"const maxPinNameBytes = 255\nif len([]byte(name)) > maxPinNameBytes {\n    name = truncateToByteLimit(name, maxPinNameBytes)\n}","typeGuard":null,"tryCatchPattern":"if err := cmdutils.ValidatePinName(name); err != nil {\n    return fmt.Errorf(\"pin name rejected: %w; shorten the name and retry\", err)\n}","preventionTips":["Truncate generated names to <=255 bytes before calling pin remote add","Count bytes, not runes, for multibyte names","Hash long identifiers into short pin names"],"tags":["pinning","validation","remote"],"backgroundTag":"name-too-long","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"}