ahmetb/kubectx · error
'%s' accepts at most one context name argument
Error message
'%s' accepts at most one context name argument
What it means
Argument-validation error from parseArgs: --readonly/-r (or --shell/-s style flags) was supplied with more than one positional argument; at most a single context name is accepted. Excess arguments make the intent ambiguous, so the op is rejected.
Source
Thrown at cmd/kubectx/flags.go:53
func parseArgs(argv []string) Op {
if len(argv) == 0 {
if cmdutil.IsInteractiveMode(os.Stdout) {
return InteractiveSwitchOp{}
}
return ListOp{}
}
if argv[0] == "--readonly" || argv[0] == "-r" {
if len(argv) == 1 {
if cmdutil.IsInteractiveMode(os.Stdout) {
return InteractiveReadonlyShellOp{}
}
return UnsupportedOp{Err: fmt.Errorf("'%s' requires a context name argument (or fzf for interactive mode)", argv[0])}
}
if len(argv) == 2 {
return ReadonlyShellOp{Target: argv[1]}
}
return UnsupportedOp{Err: fmt.Errorf("'%s' accepts at most one context name argument", argv[0])}
}
if argv[0] == "--shell" || argv[0] == "-s" {
if len(argv) == 1 {
if cmdutil.IsInteractiveMode(os.Stdout) {
return InteractiveShellOp{}
}
return UnsupportedOp{Err: fmt.Errorf("'%s' requires a context name argument (or fzf for interactive mode)", argv[0])}
}
if len(argv) == 2 {
return ShellOp{Target: argv[1]}
}
return UnsupportedOp{Err: fmt.Errorf("'%s' accepts at most one context name argument", argv[0])}
}
if argv[0] == "-d" {
if len(argv) == 1 {
if cmdutil.IsInteractiveMode(os.Stdout) {View on GitHub (pinned to 12ad6fb22e)
Solutions
- Pass only one context name after the flag
- Quote context names containing spaces
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at cmd/kubectx/flags.go:53 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of ahmetb/kubectx@12ad6fb22e (2026-09-02).
Data as JSON: /api/errors/a896022ba80f4de4.
Report an issue: GitHub.