From 165c5f04915d9ce91bbf7dbf67558cfc203c2c6b Mon Sep 17 00:00:00 2001 From: Kristoffer Dalby Date: Fri, 9 Jan 2026 08:49:37 +0000 Subject: [PATCH] cli: fix preauthkeys expire/delete argument validation The Args function incorrectly required positional arguments but the commands use --id flag. Move validation into Run function. --- cmd/headscale/cli/preauthkeys.go | 34 +++++++++++++++++++------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/cmd/headscale/cli/preauthkeys.go b/cmd/headscale/cli/preauthkeys.go index 6acb346d..498cfe4d 100644 --- a/cmd/headscale/cli/preauthkeys.go +++ b/cmd/headscale/cli/preauthkeys.go @@ -177,17 +177,20 @@ var expirePreAuthKeyCmd = &cobra.Command{ Use: "expire", Short: "Expire a preauthkey", Aliases: []string{"revoke", "exp", "e"}, - Args: func(cmd *cobra.Command, args []string) error { - if len(args) < 1 { - return errMissingParameter - } - - return nil - }, Run: func(cmd *cobra.Command, args []string) { output, _ := cmd.Flags().GetString("output") id, _ := cmd.Flags().GetUint64("id") + if id == 0 { + ErrorOutput( + errMissingParameter, + "Error: missing --id parameter", + output, + ) + + return + } + ctx, client, conn, cancel := newHeadscaleCLIWithConfig() defer cancel() defer conn.Close() @@ -213,17 +216,20 @@ var deletePreAuthKeyCmd = &cobra.Command{ Use: "delete", Short: "Delete a preauthkey", Aliases: []string{"del", "rm", "d"}, - Args: func(cmd *cobra.Command, args []string) error { - if len(args) < 1 { - return errMissingParameter - } - - return nil - }, Run: func(cmd *cobra.Command, args []string) { output, _ := cmd.Flags().GetString("output") id, _ := cmd.Flags().GetUint64("id") + if id == 0 { + ErrorOutput( + errMissingParameter, + "Error: missing --id parameter", + output, + ) + + return + } + ctx, client, conn, cancel := newHeadscaleCLIWithConfig() defer cancel() defer conn.Close()