cloudflare/cloudflared · error

You must supply at least 1 argument, the name of the virtual

Error message

You must supply at least 1 argument, the name of the virtual network you wish to add.

What it means

Argument-count guard in the `cloudflared tunnel vnet add` subcommand. It fires when the user runs the command without any positional argument; at least the virtual network name (args[0]) is required to build the create request, so the command aborts before contacting the API.

Source

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

			},
		},
	}
}

func listVirtualNetworksFlags() []cli.Flag {
	flags := make([]cli.Flag, 0)
	flags = append(flags, cfapi.VnetFilterFlags...)
	flags = append(flags, outputFormatFlag)
	return flags
}

func addVirtualNetworkCommand(c *cli.Context) error {
	sc, err := newSubcommandContext(c)
	if err != nil {
		return err
	}
	if c.NArg() < 1 {
		return errors.New("You must supply at least 1 argument, the name of the virtual network you wish to add.")
	}

	warningChecker := updater.StartWarningCheck(c)
	defer warningChecker.LogWarningIfAny(sc.log)

	args := c.Args()

	name := args.Get(0)

	comment := ""
	if c.NArg() >= 2 {
		comment = args.Get(1)
	}

	newVnet := cfapi.NewVirtualNetwork{
		Name:      name,
		Comment:   comment,
		IsDefault: c.Bool(makeDefaultFlag.Name),

View on GitHub (pinned to 2253eeeb25)

Solutions

  1. Pass the vnet name: `cloudflared tunnel vnet add my-vnet`
  2. Optionally add default-route flags afterwards per docs, e.g. `--default-route-system`
  3. Run `cloudflared tunnel vnet add --help` to see required and optional flags

Example fix

// before
$ cloudflared tunnel vnet add
// error: You must supply at least 1 argument...
// after
$ cloudflared tunnel vnet add my-vnet
Defensive patterns

Strategy: validation

Validate before calling

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

Prevention

When it happens

Trigger: Running `cloudflared tunnel vnet add` with zero arguments.

Common situations: Assuming the name is configured elsewhere or interactive; copy-pasting a command example that omitted the name placeholder; using flags-only invocations.

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/d686d44754e91215. Report an issue: GitHub.