kubernetes/kubernetes · warning
%q does not take any arguments, got %q
Error message
%q does not take any arguments, got %q
What it means
Returned from the cobra Args validator on NewHollowNodeCommand (hollow_node.go:169). The `kubemark` command takes only flags (--morph, --kubeconfig, ...) and accepts zero positional arguments; if any non-empty positional arg is passed, the validator returns this error and cobra aborts before RunE.
Source
Thrown at cmd/kubemark/app/hollow_node.go:169
// NewHollowNodeCommand creates a *cobra.Command object with default parameters
func NewHollowNodeCommand() *cobra.Command {
s := &hollowNodeConfig{
NodeLabels: make(map[string]string),
ExtendedResources: make(map[string]string),
}
cmd := &cobra.Command{
Use: "kubemark",
Long: "kubemark",
RunE: func(cmd *cobra.Command, args []string) error {
verflag.PrintAndExitIfRequested()
cliflag.PrintFlags(cmd.Flags())
return run(cmd.Context(), s)
},
Args: func(cmd *cobra.Command, args []string) error {
for _, arg := range args {
if len(arg) > 0 {
return fmt.Errorf("%q does not take any arguments, got %q", cmd.CommandPath(), args)
}
}
return nil
},
}
fs := cmd.Flags()
fs.AddGoFlagSet(goflag.CommandLine) // for flags like --docker-only
s.addFlags(fs)
return cmd
}
func run(ctx context.Context, config *hollowNodeConfig) error {
// To help debugging, immediately log version and print flags.
klog.Infof("Version: %+v", version.Get())
if !knownMorphs.Has(config.Morph) {View on GitHub (pinned to b882c60b40)
Solutions
- Remove positional arguments from the command line; pass everything as flags.
- If you meant to set the node name, use `--name <node>` instead of a positional token.
- Re-read `kubemark --help` to confirm the supported flag set.
Example fix
// before (invocation) ./kubemark --morph kubelet fake-node // after ./kubemark --morph kubelet --name fake-node
Defensive patterns
Strategy: validation
Validate before calling
// Before exec'ing kubemark, strip positional args.
func sanitizeKubemarkArgs(args []string) []string {
out := make([]string, 0, len(args))
skip := false
for _, a := range args {
if strings.HasPrefix(a, "-") {
skip = false
out = append(out, a)
continue
}
if skip { // value of a flag that takes a value
out = append(out, a)
skip = false
continue
}
// positional arg -> drop (or move to --name if it looks like a node name)
}
return out
} Try / catch
// cobra Args validator already enforces this; surface exit code != 0 as a usage error
if err := cmd.Execute(); err != nil {
// distinguish usage error (cobra returns flag.ErrHelp / pflag errors) from runtime
os.Exit(1)
} Prevention
- Always invoke kubemark with flags only; never append a bare node name.
- In automation, validate the arg list contains no non-flag tokens before launch.
- Document the flag-only contract next to wrapper scripts.
When it happens
Trigger: Invoking the binary as `kubemark somearg` or `kubemark --morph kubelet extra`. Any non-empty token after the flags triggers it.
Common situations: A wrapper script appends a node name or pod name as a positional arg by mistake; copy-pasting a CLI invocation that worked for a different binary; shell glob expanding into an argument.
Related errors
- %q does not take any arguments, got %q
- %q does not take any arguments, got %q
- Unknown morph: %v. allowed values: %v
- shell not specified
- too many arguments. expected only the shell type
AI-assisted analysis of kubernetes/kubernetes@b882c60b40 (2026-08-07).
Data as JSON: /api/errors/09679f09e95ed315.
Report an issue: GitHub.