{"record":{"id":"77b51b22fb611e03","repo":"ipfs/kubo","slug":"expecting-one-cid-argument","errorCode":null,"errorMessage":"expecting one CID argument","messagePattern":"expecting one CID argument","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/commands/pin/remotepin.go","lineNumber":160,"sourceCode":"\tType: RemotePinOutput{},\n\tRun: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {\n\t\tctx, cancel := context.WithCancel(req.Context)\n\t\tdefer cancel()\n\n\t\tenc, err := cmdenv.GetCidEncoder(req)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t// Get remote service\n\t\tc, err := getRemotePinServiceFromRequest(req, env)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t// Prepare value for Pin.cid\n\t\tif len(req.Arguments) != 1 {\n\t\t\treturn fmt.Errorf(\"expecting one CID argument\")\n\t\t}\n\t\tapi, err := cmdenv.GetApi(env, req)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tp, err := cmdutils.PathOrCidPath(req.Arguments[0])\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\trp, _, err := api.ResolvePath(ctx, p)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t// Prepare Pin.name\n\t\topts := []pinclient.AddOption{}\n\t\tif name, nameFound := req.Options[pinNameOptionName]; nameFound {","sourceCodeStart":142,"sourceCodeEnd":178,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/core/commands/pin/remotepin.go#L142-L178","documentation":"`ipfs pin remote add` requires exactly one positional argument: the CID (or path) to pin on the remote service. The pre-run handler rejects any other argument count with this error, since the remote pin request is defined by a single target.","triggerScenarios":"`ipfs pin remote add` with zero arguments (forgot the CID) or with multiple CIDs (batching is not supported by this command); RPC `pin/remote/add` calls with an empty or multi-element Arguments array.","commonSituations":"Scripts iterating over CID lists and passing them all in one call; forgetting the CID because service name/background flags were the focus; variable holding the CID is empty.","solutions":["Pass exactly one CID/path: `ipfs pin remote add --service=<svc> <cid>`.","Loop over CIDs in the script, calling `pin remote add` once per CID.","Guard for an empty CID variable before invoking the command.","Remember to pass `--service` (and `--bg`/`--name` as needed) as options, not as positional arguments."],"exampleFix":"// before (batch attempt)\nexec.Command(\"ipfs\", \"pin\", \"remote\", \"add\", \"--service\", \"pinata\", cid1, cid2).Run()\n// after\nfor _, cid := range []string{cid1, cid2} {\n  exec.Command(\"ipfs\", \"pin\", \"remote\", \"add\", \"--service\", \"pinata\", cid).Run()\n}","handlingStrategy":"validation","validationCode":"if len(cids) != 1 {\n    return fmt.Errorf(\"pin remote add takes exactly one CID, got %d\", len(cids))\n}\nif cids[0] == \"\" {\n    return errors.New(\"CID argument is empty\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Loop per-CID instead of batching arguments","Validate CID variables are non-empty before the call","Pass service/background as options, never as positional args"],"tags":["ipfs","cli","pinning","missing-argument"],"backgroundTag":"missing-required-argument","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"}