{"record":{"id":"207dcc2c68a656f4","repo":"cloudflare/cloudflared","slug":"couldn-t-parse-index-from-timeout-hop-w","errorCode":null,"errorMessage":"couldn't parse index from timeout hop: %w","messagePattern":"couldn't parse index from timeout hop: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"diagnostic/network/collector_unix.go","lineNumber":53,"sourceCode":"\tprocess := exec.CommandContext(ctx, command, args...)\n\n\treturn decodeNetworkOutputToFile(process, DecodeLine)\n}\n\nfunc DecodeLine(text string) (*Hop, error) {\n\tfields := strings.Fields(text)\n\tparts := []string{}\n\tfilter := func(s string) bool { return s != \"*\" && s != \"ms\" }\n\n\tfor _, field := range fields {\n\t\tif filter(field) {\n\t\t\tparts = append(parts, field)\n\t\t}\n\t}\n\n\tindex, err := strconv.ParseUint(parts[0], 10, 8)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"couldn't parse index from timeout hop: %w\", err)\n\t}\n\n\tif len(parts) == 1 {\n\t\treturn NewTimeoutHop(uint8(index)), nil\n\t}\n\n\tdomain := \"\"\n\trtts := []time.Duration{}\n\n\tfor _, part := range parts[1:] {\n\t\trtt, err := strconv.ParseFloat(part, 64)\n\t\tif err != nil {\n\t\t\tdomain += part + \" \"\n\t\t} else {\n\t\t\trtts = append(rtts, time.Duration(rtt*MicrosecondsFactor))\n\t\t}\n\t}\n","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/cloudflare/cloudflared/blob/2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f/diagnostic/network/collector_unix.go#L35-L71","documentation":"DecodeLine (Unix) parses traceroute output lines for timeout hops, expecting the first whitespace-separated field to be the hop index. When strconv.ParseUint cannot parse parts[0] as an integer, the line does not follow the expected traceroute format and this wrapped error is returned, failing network diagnostic decoding.","triggerScenarios":"Decoding a traceroute line whose first token is not a number — e.g. a header line like 'traceroute to ...', warning lines, or output from a traceroute variant with a different column layout piped into Decode.","commonSituations":"Running an unsupported traceroute implementation (busybox, musl variants) whose output format differs; traceroute emits non-hop lines (DNS warnings, headers) that reach the timeout-hop branch; locale changes the output format.","solutions":["Ensure the standard iputils traceroute is installed and used (check which traceroute).","Verify traceroute output manually for the target host and confirm hop lines parse as expected.","Fix locale-related formatting (LC_ALL=C) if numeric output is localized.","Handle the error in the caller by skipping/reporting unparseable lines rather than treating the whole diagnostic as fatal, if a traceroute variant must be tolerated."],"exampleFix":"// before\nhops, _, err := network.Collect(ctx, config)\nif err != nil {\n\treturn err\n}\n// after\nhops, _, err := network.Collect(ctx, config)\nif err != nil {\n\tvar parseErr *strconv.NumError\n\tif errors.As(err, &parseErr) {\n\t\t// non-numeric hop index: incompatible traceroute output\n\t\tlog.Warn().Err(err).Msg(\"unexpected traceroute format\")\n\t}\n\treturn fmt.Errorf(\"network collect: %w\", err)\n}","handlingStrategy":"validation","validationCode":"// pre-check the traceroute binary and a sample of its output format\nout, err := exec.Command(\"traceroute\", \"--help\").Output()\nif err != nil {\n\t// unsupported or missing traceroute\n}","typeGuard":null,"tryCatchPattern":"hops, err := network.Collect(ctx, cfg)\nvar numErr *strconv.NumError\nif errors.As(err, &numErr) {\n\t// incompatible traceroute output: log raw tee output for debugging\n}","preventionTips":["Install standard iputils traceroute on Linux hosts","Run with LC_ALL=C to keep numeric output stable","Inspect raw traceroute output when decoding fails","Keep the diagnostic package updated for new traceroute variants"],"tags":["diagnostics","network","traceroute","parsing"],"backgroundTag":"invalid-argument-format","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"}