ipfs/kubo · error
no id specified
Error message
no id specified
What it means
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.
Source
Thrown at core/commands/p2p.go:660
},
Arguments: []cmds.Argument{
cmds.StringArg("id", false, false, "Stream identifier"),
},
Options: []cmds.Option{
cmds.BoolOption(p2pAllOptionName, "a", "Close all streams."),
},
Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {
n, err := p2pGetNode(env)
if err != nil {
return err
}
closeAll, _ := req.Options[p2pAllOptionName].(bool)
var handlerID uint64
if !closeAll {
if len(req.Arguments) == 0 {
return errors.New("no id specified")
}
handlerID, err = strconv.ParseUint(req.Arguments[0], 10, 64)
if err != nil {
return err
}
}
toClose := make([]*p2p.Stream, 0, 1)
n.P2P.Streams.Lock()
for id, stream := range n.P2P.Streams.Streams {
if !closeAll && handlerID != id {
continue
}
toClose = append(toClose, stream)
if !closeAll {
break
}View on GitHub (pinned to 329838acdf)
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.
Example fix
// before (empty id var)
exec.Command("ipfs", "p2p", "close", id).Run()
// after
if id == "" { return errors.New("no handler id; run `ipfs p2p stream ls`") }
exec.Command("ipfs", "p2p", "close", id).Run() Defensive patterns
Strategy: validation
Validate before calling
if !all && id == "" {
return errors.New("handler id required (see `ipfs p2p stream ls`) or use --all")
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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`.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- can't combine --all with other matching options
- expecting one CID argument
- supernode routing was never fully implemented and has been r
- unrecognized routing option: %s
- keystore name for backing up old key must be provided
AI-assisted analysis of ipfs/kubo@329838acdf (2026-09-03).
Data as JSON: /api/errors/d078c10dee7374c5.
Report an issue: GitHub.