{"record":{"id":"c170250ac28c20ad","repo":"cloudflare/cloudflared","slug":"failed-to-build-quick-tunnel-request-body","errorCode":null,"errorMessage":"failed to build quick tunnel request body","messagePattern":"failed to build quick tunnel request body","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/cloudflared/tunnel/quick_tunnel.go","lineNumber":61,"sourceCode":"func RunQuickTunnel(sc *subcommandContext) error {\n\tsc.log.Info().Msg(disclaimer)\n\tsc.log.Info().Msg(\"Requesting new quick Tunnel on trycloudflare.com...\")\n\n\t// TODO(TUN-10798): register the --allowed-mail flag so this path becomes reachable.\n\tallowedMail := sc.c.StringSlice(flags.AllowedMail)\n\tisProtected := len(allowedMail) > 0\n\n\tclient := http.Client{\n\t\tTransport: &http.Transport{\n\t\t\tTLSHandshakeTimeout:   httpTimeout,\n\t\t\tResponseHeaderTimeout: httpTimeout,\n\t\t},\n\t\tTimeout: httpTimeout,\n\t}\n\n\treqBody, err := buildQuickTunnelRequestBody(isProtected)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to build quick tunnel request body\")\n\t}\n\n\treq, err := http.NewRequest(http.MethodPost, fmt.Sprintf(\"%s/tunnel\", sc.c.String(\"quick-service\")), bytes.NewReader(reqBody))\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to build quick tunnel request\")\n\t}\n\treq.Header.Add(\"Content-Type\", \"application/json\")\n\treq.Header.Add(\"User-Agent\", buildInfo.UserAgent())\n\n\tresp, err := client.Do(req)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to request quick Tunnel\")\n\t}\n\tdefer func() { _ = resp.Body.Close() }()\n\n\t// This will read the entire response into memory so we can print it in case of error\n\trespBody, err := io.ReadAll(resp.Body)\n\tif err != nil {","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/cloudflare/cloudflared/blob/2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f/cmd/cloudflared/tunnel/quick_tunnel.go#L43-L79","documentation":"RunQuickTunnel builds the JSON request body for registering a free trycloudflare.com quick tunnel via buildQuickTunnelRequestBody. If marshaling that body fails, the error is wrapped as 'failed to build quick tunnel request body' and quick-tunnel startup aborts before any HTTP request is made.","triggerScenarios":"Running `cloudflared tunnel --url ...` (quick tunnel mode) when buildQuickTunnelRequestBody cannot serialize the registration payload (JSON marshal failure of the request structure).","commonSituations":"Rare; typically triggered by internal issues such as unsupported values in the request payload or corrupted binary/build; most users hit this on old or mismatched cloudflared builds.","solutions":["Retry `cloudflared tunnel --url http://localhost:PORT` — transient/internal failures usually don't recur.","Upgrade cloudflared to the latest release to rule out a build/version bug.","Check the wrapped inner error (json marshal detail) for the offending field.","Use a named tunnel with credentials instead of quick tunnels if the issue persists."],"exampleFix":"// before\ncloudflared tunnel --url http://localhost:8080  # old build, body marshal fails\n// after\n# upgrade then retry\ncloudflared update\ncloudflared tunnel --url http://localhost:8080","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"reqBody, err := buildQuickTunnelRequestBody(isProtected)\nif err != nil {\n\treturn errors.Wrap(err, \"failed to build quick tunnel request body\")\n}","preventionTips":["Keep cloudflared up to date; this is an internal marshal path","Retry quick tunnel creation on sporadic failures","Prefer named tunnels for production workloads","Inspect the wrapped inner error for the failing payload field"],"tags":["quick-tunnel","json","network"],"backgroundTag":"json-marshal-failed","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"}