{"record":{"id":"a5a04df5564ecbf1","repo":"cloudflare/cloudflared","slug":"there-should-only-be-1-non-deleted-virtual-network","errorCode":null,"errorMessage":"there should only be 1 non-deleted virtual network named %s","messagePattern":"there should only be 1 non-deleted virtual network named (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/cloudflared/tunnel/vnets_subcommands.go","lineNumber":273,"sourceCode":"}\n\nfunc getVnetId(sc *subcommandContext, input string) (uuid.UUID, error) {\n\tval, err := uuid.Parse(input)\n\tif err == nil {\n\t\treturn val, nil\n\t}\n\n\tfilter := cfapi.NewVnetFilter()\n\tfilter.WithDeleted(false)\n\tfilter.ByName(input)\n\n\tvnets, err := sc.listVirtualNetworks(filter)\n\tif err != nil {\n\t\treturn uuid.Nil, err\n\t}\n\n\tif len(vnets) != 1 {\n\t\treturn uuid.Nil, fmt.Errorf(\"there should only be 1 non-deleted virtual network named %s\", input)\n\t}\n\n\treturn vnets[0].ID, nil\n}\n\nfunc formatAndPrintVnetsList(vnets []*cfapi.VirtualNetwork) {\n\tconst (\n\t\tminWidth = 0\n\t\ttabWidth = 8\n\t\tpadding  = 1\n\t\tpadChar  = ' '\n\t\tflags    = 0\n\t)\n\n\twriter := tabwriter.NewWriter(os.Stdout, minWidth, tabWidth, padding, padChar, flags)\n\tdefer writer.Flush()\n\n\t_, _ = fmt.Fprintln(writer, \"ID\\tNAME\\tIS DEFAULT\\tCOMMENT\\tCREATED\\tDELETED\\t\")","sourceCodeStart":255,"sourceCodeEnd":291,"githubUrl":"https://github.com/cloudflare/cloudflared/blob/2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f/cmd/cloudflared/tunnel/vnets_subcommands.go#L255-L291","documentation":"getVnetId resolves a virtual network name to its UUID by listing virtual networks filtered by name. The API contract expects exactly one non-deleted virtual network per name; when the list returns anything other than exactly one entry, cloudflared cannot resolve the name and raises this error.","triggerScenarios":"Running route/vnet subcommands (`cloudflared tunnel route ip add/delete`, `cloudflared tunnel network add/delete/update` path via getVnetId callers) with a vnet name that matches zero non-deleted virtual networks or is duplicated.","commonSituations":"Typo in the virtual network name; vnet was deleted; duplicate vnet names created in the account; operating against an account different from where the vnet lives.","solutions":["List virtual networks with `cloudflared tunnel network list` and use the exact existing name (or its UUID).","Delete or rename duplicates so each name is unique among non-deleted vnets.","Create the vnet first with `cloudflared tunnel network add <name>` if none exists."],"exampleFix":"// before\ncloudflared tunnel route ip add 10.0.0.0/24 vnet-prod-typo\n// after\ncloudflared tunnel network list\ncloudflared tunnel route ip add 10.0.0.0/24 vnet-prod","handlingStrategy":"validation","validationCode":"out, _ := exec.Command(\"cloudflared\", \"tunnel\", \"network\", \"list\").Output()\nif !strings.Contains(string(out), vnetName) {\n    return fmt.Errorf(\"virtual network %q does not exist\", vnetName)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run `cloudflared tunnel network list` before route commands to confirm names.","Keep virtual network names unique per account.","Create the vnet before adding routes that reference it."],"tags":["cli","not-found","virtual-network","ambiguity"],"backgroundTag":"entity-not-found","analyzedSha":"2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f","analyzedAt":"2026-09-06T04:14:33.757Z","contentChangedAt":"2026-09-06T04:14:33.757Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}