cloudflare/cloudflared · error

You must supply exactly one argument, either the ID or name

Error message

You must supply exactly one argument, either the ID or name of the virtual network to delete

What it means

Argument-count guard in the `cloudflared tunnel vnet delete` subcommand. It fires when the user supplies no positional argument; the command needs exactly one argument, the ID or name of the virtual network to delete, which it resolves to a vnet ID via getVnetId.

Source

Thrown at cmd/cloudflared/tunnel/vnets_subcommands.go:199

		return renderOutput(outputFormat, vnets)
	}

	if len(vnets) > 0 {
		formatAndPrintVnetsList(vnets)
	} else {
		fmt.Println("No virtual networks were found for the given filter flags. You can use 'cloudflared tunnel vnet add' to add a virtual network.")
	}

	return nil
}

func deleteVirtualNetworkCommand(c *cli.Context) error {
	sc, err := newSubcommandContext(c)
	if err != nil {
		return err
	}
	if c.NArg() < 1 {
		return errors.New("You must supply exactly one argument, either the ID or name of the virtual network to delete")
	}

	input := c.Args().Get(0)
	vnetId, err := getVnetId(sc, input)
	if err != nil {
		return err
	}

	forceDelete := false
	if c.IsSet(vnetForceDeleteFlag.Name) {
		forceDelete = c.Bool(vnetForceDeleteFlag.Name)
	}

	if err := sc.deleteVirtualNetwork(vnetId, forceDelete); err != nil {
		return errors.Wrap(err, "API error")
	}
	fmt.Printf("Successfully deleted virtual network '%s'\n", input)
	return nil

View on GitHub (pinned to 2253eeeb25)

Solutions

  1. Pass the vnet ID or name: `cloudflared tunnel vnet delete my-vnet`
  2. Run `cloudflared tunnel vnet` (list) to find the exact ID/name
  3. If the vnet was already deleted, this validation runs before lookup — verify it still exists via the list command

Example fix

// before
$ cloudflared tunnel vnet delete
// error: You must supply exactly one argument...
// after
$ cloudflared tunnel vnet delete my-vnet
Defensive patterns

Strategy: validation

Validate before calling

if [ -z "$1" ]; then echo "usage: cloudflared tunnel vnet delete <ID|NAME>" >&2; exit 1; fi
cloudflared tunnel vnet delete "$1"

Prevention

When it happens

Trigger: Running `cloudflared tunnel vnet delete` with zero positional arguments.

Common situations: Forgetting the vnet name after deleting similarly-named resources; expecting an interactive picker; confusion with delete-by-flag patterns in other CLIs.

Understand the failure class

Background: "no subcommand specified" and "... is required": CLI errors when a required argument is missing — this error's family across 13 libraries.

Related errors


AI-assisted analysis of cloudflare/cloudflared@2253eeeb25 (2026-09-06). Data as JSON: /api/errors/c6d9f8028cd4465a. Report an issue: GitHub.