{"record":{"id":"c6d9f8028cd4465a","repo":"cloudflare/cloudflared","slug":"you-must-supply-exactly-one-argument-either-the-i","errorCode":null,"errorMessage":"You must supply exactly one argument, either the ID or name of the virtual network to delete","messagePattern":"You must supply exactly one argument, either the ID or name of the virtual network to delete","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/cloudflared/tunnel/vnets_subcommands.go","lineNumber":199,"sourceCode":"\t\treturn renderOutput(outputFormat, vnets)\n\t}\n\n\tif len(vnets) > 0 {\n\t\tformatAndPrintVnetsList(vnets)\n\t} else {\n\t\tfmt.Println(\"No virtual networks were found for the given filter flags. You can use 'cloudflared tunnel vnet add' to add a virtual network.\")\n\t}\n\n\treturn nil\n}\n\nfunc deleteVirtualNetworkCommand(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 exactly one argument, either the ID or name of the virtual network to delete\")\n\t}\n\n\tinput := c.Args().Get(0)\n\tvnetId, err := getVnetId(sc, input)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tforceDelete := false\n\tif c.IsSet(vnetForceDeleteFlag.Name) {\n\t\tforceDelete = c.Bool(vnetForceDeleteFlag.Name)\n\t}\n\n\tif err := sc.deleteVirtualNetwork(vnetId, forceDelete); err != nil {\n\t\treturn errors.Wrap(err, \"API error\")\n\t}\n\tfmt.Printf(\"Successfully deleted virtual network '%s'\\n\", input)\n\treturn nil","sourceCodeStart":181,"sourceCodeEnd":217,"githubUrl":"https://github.com/cloudflare/cloudflared/blob/2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f/cmd/cloudflared/tunnel/vnets_subcommands.go#L181-L217","documentation":"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.","triggerScenarios":"Running `cloudflared tunnel vnet delete` with zero positional arguments.","commonSituations":"Forgetting the vnet name after deleting similarly-named resources; expecting an interactive picker; confusion with delete-by-flag patterns in other CLIs.","solutions":["Pass the vnet ID or name: `cloudflared tunnel vnet delete my-vnet`","Run `cloudflared tunnel vnet` (list) to find the exact ID/name","If the vnet was already deleted, this validation runs before lookup — verify it still exists via the list command"],"exampleFix":"// before\n$ cloudflared tunnel vnet delete\n// error: You must supply exactly one argument...\n// after\n$ cloudflared tunnel vnet delete my-vnet","handlingStrategy":"validation","validationCode":"if [ -z \"$1\" ]; then echo \"usage: cloudflared tunnel vnet delete <ID|NAME>\" >&2; exit 1; fi\ncloudflared tunnel vnet delete \"$1\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Verify the vnet exists via `cloudflared tunnel vnet` list first","Use the stable UUID to avoid name ambiguity","Quote names containing spaces"],"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"}