{"record":{"id":"d686d44754e91215","repo":"cloudflare/cloudflared","slug":"you-must-supply-at-least-1-argument-the-name-of-t","errorCode":null,"errorMessage":"You must supply at least 1 argument, the name of the virtual network you wish to add.","messagePattern":"You must supply at least 1 argument, the name of the virtual network you wish to add\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/cloudflared/tunnel/vnets_subcommands.go","lineNumber":123,"sourceCode":"\t\t\t},\n\t\t},\n\t}\n}\n\nfunc listVirtualNetworksFlags() []cli.Flag {\n\tflags := make([]cli.Flag, 0)\n\tflags = append(flags, cfapi.VnetFilterFlags...)\n\tflags = append(flags, outputFormatFlag)\n\treturn flags\n}\n\nfunc addVirtualNetworkCommand(c *cli.Context) error {\n\tsc, err := newSubcommandContext(c)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif c.NArg() < 1 {\n\t\treturn errors.New(\"You must supply at least 1 argument, the name of the virtual network you wish to add.\")\n\t}\n\n\twarningChecker := updater.StartWarningCheck(c)\n\tdefer warningChecker.LogWarningIfAny(sc.log)\n\n\targs := c.Args()\n\n\tname := args.Get(0)\n\n\tcomment := \"\"\n\tif c.NArg() >= 2 {\n\t\tcomment = args.Get(1)\n\t}\n\n\tnewVnet := cfapi.NewVirtualNetwork{\n\t\tName:      name,\n\t\tComment:   comment,\n\t\tIsDefault: c.Bool(makeDefaultFlag.Name),","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/cloudflare/cloudflared/blob/2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f/cmd/cloudflared/tunnel/vnets_subcommands.go#L105-L141","documentation":"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.","triggerScenarios":"Running `cloudflared tunnel vnet add` with zero arguments.","commonSituations":"Assuming the name is configured elsewhere or interactive; copy-pasting a command example that omitted the name placeholder; using flags-only invocations.","solutions":["Pass the vnet name: `cloudflared tunnel vnet add my-vnet`","Optionally add default-route flags afterwards per docs, e.g. `--default-route-system`","Run `cloudflared tunnel vnet add --help` to see required and optional flags"],"exampleFix":"// before\n$ cloudflared tunnel vnet add\n// error: You must supply at least 1 argument...\n// after\n$ cloudflared tunnel vnet add my-vnet","handlingStrategy":"validation","validationCode":"if [ -z \"$1\" ]; then echo \"usage: cloudflared tunnel vnet add <NAME>\" >&2; exit 1; fi\ncloudflared tunnel vnet add \"$1\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always include the vnet name as the first positional argument","Quote names with spaces","Consult `--help` for optional flags like default route system"],"tags":["cli","cloudflared","virtual-network"],"backgroundTag":"missing-cli-argument","analyzedSha":"2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f","analyzedAt":"2026-09-06T04:14:33.757Z","contentChangedAt":"2026-09-06T04:14:33.757Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}