{"record":{"id":"d078c10dee7374c5","repo":"ipfs/kubo","slug":"no-id-specified","errorCode":null,"errorMessage":"no id specified","messagePattern":"no id specified","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/commands/p2p.go","lineNumber":660,"sourceCode":"\t},\n\tArguments: []cmds.Argument{\n\t\tcmds.StringArg(\"id\", false, false, \"Stream identifier\"),\n\t},\n\tOptions: []cmds.Option{\n\t\tcmds.BoolOption(p2pAllOptionName, \"a\", \"Close all streams.\"),\n\t},\n\tRun: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {\n\t\tn, err := p2pGetNode(env)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tcloseAll, _ := req.Options[p2pAllOptionName].(bool)\n\t\tvar handlerID uint64\n\n\t\tif !closeAll {\n\t\t\tif len(req.Arguments) == 0 {\n\t\t\t\treturn errors.New(\"no id specified\")\n\t\t\t}\n\n\t\t\thandlerID, err = strconv.ParseUint(req.Arguments[0], 10, 64)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t\ttoClose := make([]*p2p.Stream, 0, 1)\n\t\tn.P2P.Streams.Lock()\n\t\tfor id, stream := range n.P2P.Streams.Streams {\n\t\t\tif !closeAll && handlerID != id {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\ttoClose = append(toClose, stream)\n\t\t\tif !closeAll {\n\t\t\t\tbreak\n\t\t\t}","sourceCodeStart":642,"sourceCodeEnd":678,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/core/commands/p2p.go#L642-L678","documentation":"The `ipfs p2p close` command requires a handler ID (the numeric identifier printed by `ipfs p2p stream ls`/listeners listing) unless `--all` is given. When no positional argument and no `--all` flag are supplied, the command has nothing to close and throws this error during request parsing.","triggerScenarios":"Calling `ipfs p2p close` with zero arguments and without `--all`; programmatically calling `p2p close` via the RPC API with an empty `Arguments` array while `p2pAllOptionName` is false.","commonSituations":"Scripts where the handler ID variable is empty because a previous `p2p stream ls | grep | awk` pipeline failed to match; users forgetting that closing requires the ID shown in `ipfs p2p stream ls`.","solutions":["Pass the handler ID as the first argument: `ipfs p2p close <handlerID>`.","Get the ID first with `ipfs p2p stream ls` (streams) or `ipfs p2p listen ls` style listings.","Add `--all` if you intend to close every active p2p stream/listener.","Guard scripts: abort if the ID variable is empty instead of calling the command with no argument."],"exampleFix":"// before (empty id var)\nexec.Command(\"ipfs\", \"p2p\", \"close\", id).Run()\n// after\nif id == \"\" { return errors.New(\"no handler id; run `ipfs p2p stream ls`\") }\nexec.Command(\"ipfs\", \"p2p\", \"close\", id).Run()","handlingStrategy":"validation","validationCode":"if !all && id == \"\" {\n    return errors.New(\"handler id required (see `ipfs p2p stream ls`) or use --all\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Fetch IDs with `ipfs p2p stream ls` before closing","Abort scripts on empty ID variables instead of passing empty args","Prefer --all only when intentionally closing everything"],"tags":["cli","ipfs","p2p","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"}