cloudflare/cloudflared · error

couldn't parse index from timeout hop: %w

Error message

couldn't parse index from timeout hop: %w

What it means

DecodeLine (Windows) parses tracert output lines, expecting the first field to be the numeric hop index. When strconv.ParseUint fails on parts[0], the line does not match the expected tracert format and this wrapped error is returned, failing the decode of Windows network diagnostics.

Source

Thrown at diagnostic/network/collector_windows.go:52

	return decodeNetworkOutputToFile(command, DecodeLine)
}

func DecodeLine(text string) (*Hop, error) {
	const requestTimedOut = "Request timed out."

	fields := strings.Fields(text)
	parts := []string{}
	filter := func(s string) bool { return s != "*" && s != "ms" }

	for _, field := range fields {
		if filter(field) {
			parts = append(parts, field)
		}
	}

	index, err := strconv.ParseUint(parts[0], 10, 8)
	if err != nil {
		return nil, fmt.Errorf("couldn't parse index from timeout hop: %w", err)
	}

	domain := ""
	rtts := []time.Duration{}

	for _, part := range parts[1:] {

		rtt, err := strconv.ParseFloat(strings.TrimLeft(part, "<"), 64)

		if err != nil {
			domain += part + " "
		} else {
			rtts = append(rtts, time.Duration(rtt*MicrosecondsFactor))
		}
	}

	domain, _ = strings.CutSuffix(domain, " ")
	// If the domain is equal to "Request timed out." then we build a

View on GitHub (pinned to 2253eeeb25)

Solutions

  1. Run tracert on the affected machine and compare its exact output with what the parser expects.
  2. Set the system/process locale to English or ensure consistent output (chcp 65001 / localized format differences).
  3. Ensure the standard Windows tracert.exe is used, not a third-party substitute in PATH.
  4. In a patch, skip non-hop lines instead of failing the whole decode.
Defensive patterns

Strategy: validation

Validate before calling

// verify expected tracert output shape before decoding
out, err := exec.Command("tracert", "-d", "-h", "1", "127.0.0.1").Output()
if err != nil || !strings.Contains(string(out), "\n") {
	// unexpected tracert environment
}

Try / catch

hops, _, err := network.Collect(ctx, cfg)
var numErr *strconv.NumError
if errors.As(err, &numErr) {
	// non-numeric hop index: check tracert locale/variant
}

Prevention

When it happens

Trigger: Decoding a tracert line whose first token is not a number: tracert header lines ('Tracing route to ...'), 'Request timed out' summary lines, or localized tracert output where formatting differs from the expected parser.

Common situations: Windows systems with a non-English locale where tracert output wording/layout differs; tracert variants or third-party tools emitting different formats; header/warning lines reaching the timeout-hop parse branch.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


AI-assisted analysis of cloudflare/cloudflared@2253eeeb25 (2026-09-06). Data as JSON: /api/errors/bc9847ce020102c5. Report an issue: GitHub.