kubernetes/kops · error

too many arguments

Error message

too many arguments

What it means

The delete secret command accepts at most one secret name. Passing more than one positional argument triggers "too many arguments". The CLI intentionally does not support batch deletion in one invocation.

Source

Thrown at cmd/kops/delete_secret.go:69

	cmd := &cobra.Command{
		Use:     "secret SECRET_NAME...",
		Short:   deleteSecretShort,
		Example: deleteSecretExample,
		Args: func(cmd *cobra.Command, args []string) error {
			if len(args) > 0 && args[0] == "sshpublickey" {
				options.SecretType = args[0]
				return nil
			}

			if len(args) > 0 && args[0] == "secret" {
				args = args[1:]
			}

			if len(args) == 0 {
				return fmt.Errorf("secret name is required")
			}
			if len(args) > 1 {
				return fmt.Errorf("too many arguments")
			}
			options.SecretNames = args
			options.ClusterName = rootCommand.ClusterName(true)

			if options.ClusterName == "" {
				return fmt.Errorf("--name is required")
			}

			return nil
		},
		ValidArgsFunction: completeSecretNames(f),
		RunE: func(cmd *cobra.Command, args []string) error {
			return RunDeleteSecret(cmd.Context(), f, out, options)
		},
	}

	return cmd
}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Run the command once per secret: kops delete secret <name> --name <cluster>
  2. Quote names containing spaces: kops delete secret "my secret"
  3. Check `kops delete secret --help` for accepted argument count

Example fix

// before
kops delete secret dockerconfig admin --name mycluster.k8s.local
// after
kops delete secret dockerconfig --name mycluster.k8s.local
kops delete secret admin --name mycluster.k8s.local
Defensive patterns

Strategy: validation

Validate before calling

# shell: ensure only one positional arg
set -- "$@"
if [ "$#" -ne 1 ]; then echo "pass exactly one secret name"; exit 1; fi

Prevention

When it happens

Trigger: `kops delete secret name1 name2 ...` with two or more positional args after stripping the optional "secret" keyword.

Common situations: Attempting batch deletion; passing extra flags positionally or quoting mistakes that split one name into multiple args.

Related errors


AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05). Data as JSON: /api/errors/dff366e0afe3eef1. Report an issue: GitHub.