go-delve/delve · error
unrecognized argument to %s %s
Error message
unrecognized argument to %s %s
What it means
readGoroutinesFilterKind maps a filter kind token to a GoroutineField. Tokens other than the recognized kinds (curloc, userloc, label, function, running, user, file, line) are rejected with this error, echoing both the flag and the offending token.
Source
Thrown at service/api/command.go:145
}
switch args[i] {
case "curloc":
return GoroutineCurrentLoc, nil
case "userloc":
return GoroutineUserLoc, nil
case "goloc":
return GoroutineGoLoc, nil
case "startloc":
return GoroutineStartLoc, nil
case "label":
return GoroutineLabel, nil
case "running":
return GoroutineRunning, nil
case "user":
return GoroutineUser, nil
default:
return GoroutineFieldNone, fmt.Errorf("unrecognized argument to %s %s", args[i-1], args[i])
}
}
func readGoroutinesFilter(args []string, pi *int) (*ListGoroutinesFilter, error) {
r := new(ListGoroutinesFilter)
var err error
r.Kind, err = readGoroutinesFilterKind(args, *pi+1)
if err != nil {
return nil, err
}
*pi++
switch r.Kind {
case GoroutineRunning, GoroutineUser:
return r, nil
}
if *pi+1 >= len(args) {
return nil, fmt.Errorf("%s %s needs to be followed by an expression", args[*pi-1], args[*pi])
}View on GitHub (pinned to a23773e6c3)
Solutions
- Replace the kind with one of: curloc, userloc, label, function, running, user, file, line.
- Remember that 'running' and 'user' take no expression; other kinds need a following expression.
- Fix capitalization - kinds are lowercase.
Example fix
// before
cmd.ProcessLine("goroutines -with status running")
// after
cmd.ProcessLine("goroutines -with running") Defensive patterns
Strategy: validation
Validate before calling
var validKinds = map[string]bool{"curloc": true, "userloc": true, "label": true, "function": true, "running": true, "user": true, "file": true, "line": true}
// validate kind token before building the arg list
if !validKinds[kind] { return fmt.Errorf("kind %q not supported", kind) } Try / catch
if _, err := api.ParseGoroutineArgs([]string{"-with", kind}); err != nil {
return fmt.Errorf("invalid filter kind: %v", err)
} Prevention
- Only use lowercase kind names from the switch in readGoroutinesFilterKind
- Remember 'running' and 'user' take no value
- Check spelling against the documented set
When it happens
Trigger: Calling ParseGoroutineArgs with a filter flag followed by an invalid kind, e.g. 'goroutines -with state running' or 'goroutines -without loc main.go:10'.
Common situations: Using synonym words the parser does not know (e.g. 'name', 'location', 'status'); case-sensitivity mistakes ('Curloc'); confusion between the filter kind and the filter value.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- illegal commandline '%s'
- %s must be followed by an argument
- %s %s needs to be followed by an expression
- %q is not a valid format
- unknown option %q
AI-assisted analysis of go-delve/delve@a23773e6c3 (2026-08-31).
Data as JSON: /api/errors/7db5030332588a25.
Report an issue: GitHub.