{"record":{"id":"9d3c21265e904536","repo":"cloudflare/cloudflared","slug":"expected-to-find-a-single-tunnel-with-uuid-v-but","errorCode":null,"errorMessage":"Expected to find a single tunnel with uuid %v but found %d tunnels.","messagePattern":"Expected to find a single tunnel with uuid (.+?) but found (.+?) tunnels\\.","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/cloudflared/tunnel/subcommands.go","lineNumber":611,"sourceCode":"\n\tif len(clients) > 0 {\n\t\tformatAndPrintConnectionsList(info, c.Bool(\"show-recently-disconnected\"))\n\t} else {\n\t\tfmt.Printf(\"Your tunnel %s does not have any active connection.\\n\", tunnelID)\n\t}\n\n\treturn nil\n}\n\nfunc getTunnel(sc *subcommandContext, tunnelID uuid.UUID) (*cfapi.Tunnel, error) {\n\tfilter := cfapi.NewTunnelFilter()\n\tfilter.ByTunnelID(tunnelID)\n\ttunnels, err := sc.list(filter)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif len(tunnels) != 1 {\n\t\treturn nil, errors.Errorf(\"Expected to find a single tunnel with uuid %v but found %d tunnels.\", tunnelID, len(tunnels))\n\t}\n\treturn tunnels[0], nil\n}\n\nfunc formatAndPrintConnectionsList(tunnelInfo Info, showRecentlyDisconnected bool) {\n\twriter := tabWriter()\n\tdefer func() { _ = writer.Flush() }()\n\n\t// Print the general tunnel info table\n\t_, _ = fmt.Fprintf(writer, \"NAME:     %s\\nID:       %s\\nCREATED:  %s\\n\\n\", tunnelInfo.Name, tunnelInfo.ID, tunnelInfo.CreatedAt)\n\n\t// Determine whether to print the connector table\n\tshouldDisplayTable := false\n\tfor _, c := range tunnelInfo.Connectors {\n\t\tconns := fmtConnections(c.Connections, showRecentlyDisconnected)\n\t\tif len(conns) > 0 {\n\t\t\tshouldDisplayTable = true\n\t\t}","sourceCodeStart":593,"sourceCodeEnd":629,"githubUrl":"https://github.com/cloudflare/cloudflared/blob/2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f/cmd/cloudflared/tunnel/subcommands.go#L593-L629","documentation":"getTunnel queries the Cloudflare API filtered by tunnel UUID and asserts exactly one result. When the API returns zero matches (never existed / deleted / different account) or more than one (unexpected server-side state), it errors with 'Expected to find a single tunnel with uuid %v but found %d tunnels.'","triggerScenarios":"Calling `cloudflared tunnel info <uuid>` (or delete by ID) with a UUID that does not exist in the currently authenticated account, or an API response returning duplicate/empty rows for the ByTunnelID filter.","commonSituations":"Querying a tunnel from the wrong Cloudflare account (stale cert.pem for another account); tunnel already deleted; copy-pasting a UUID across accounts or environments (staging vs prod); API inconsistency returning duplicates.","solutions":["Verify the UUID belongs to the logged-in account: `cloudflared tunnel list` and cross-check","Run `cloudflared tunnel login` to ensure the cert.pem matches the intended account","If found 0: the tunnel was deleted or never existed — create a new one or fix the ID","If found >1: retry; if persistent, report to Cloudflare since duplicate UUIDs are unexpected"],"exampleFix":"// before\ncloudflared tunnel info 11111111-1111-1111-1111-111111111111   # other account\n// after\ncloudflared tunnel login   # switch to correct account\ncloudflared tunnel info 11111111-1111-1111-1111-111111111111","handlingStrategy":"retry","validationCode":"out, _ := exec.Command(\"cloudflared\", \"tunnel\", \"list\", \"--output\", \"json\").Output()\nvar tunnels []map[string]any\njson.Unmarshal(out, &tunnels)\nfound := 0\nfor _, t := range tunnels { if t[\"id\"] == wantID { found++ } }\nif found != 1 { return fmt.Errorf(\"uuid %s matches %d tunnels in this account\", wantID, found) }","typeGuard":null,"tryCatchPattern":"tunnels, err := sc.list(filter)\nif err != nil { return nil, err }\nif len(tunnels) != 1 {\n\t// retry once for transient API inconsistency, else surface\n\treturn nil, fmt.Errorf(\"expected 1 tunnel for uuid %v, found %d\", tunnelID, len(tunnels))\n}","preventionTips":["Confirm account identity (cert.pem) matches the tunnel's account before info/delete","Keep a registry mapping tunnel IDs to accounts/environments","Re-login after switching Cloudflare accounts","Treat duplicate UUID results as an API bug and report with request IDs"],"tags":["cloudflared","api","tunnel","account"],"backgroundTag":"unexpected-response-shape","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"}