cloudflare/cloudflared · error
error parsing files max field '%s': %w
Error message
error parsing files max field '%s': %w
What it means
ParseSysctlFileDescriptorInformation parses whitespace-separated sysctl file-descriptor limits and expects the maximum at whitespace field index 2. This error is returned when strconv.ParseUint fails on that field, i.e. the third token is not a base-10 unsigned integer. The wrapped strconv error and the offending string are included in the message.
Source
Thrown at diagnostic/system_collector_utils.go:243
"expected file descriptor information to have %d fields got %d: %w",
fileDescriptorLimitsFields,
len(fields),
ErrInsuficientFields,
)
}
fileDescriptorCurrent, err := strconv.ParseUint(fields[openFilesField], 10, 64)
if err != nil {
return nil, fmt.Errorf(
"error parsing files current field '%s': %w",
fields[openFilesField],
err,
)
}
fileDescriptorMaximum, err := strconv.ParseUint(fields[maxFilesField], 10, 64)
if err != nil {
return nil, fmt.Errorf("error parsing files max field '%s': %w", fields[maxFilesField], err)
}
return &FileDescriptorInformation{fileDescriptorMaximum, fileDescriptorCurrent}, nil
}
func ParseFileDescriptorInformationFromKV(
output string,
fileDescriptorMaximumKey string,
fileDescriptorCurrentKey string,
) (*FileDescriptorInformation, error) {
mapper := func(field string) (uint64, error) {
return strconv.ParseUint(field, 10, 64)
}
pairs := findColonSeparatedPairs(output, []string{fileDescriptorMaximumKey, fileDescriptorCurrentKey}, mapper)
fileDescriptorMaximum, exists := pairs[fileDescriptorMaximumKey]
if !exists {View on GitHub (pinned to 2253eeeb25)
Solutions
- Inspect the raw output and ensure the third whitespace-separated token is a plain decimal integer
- Strip units, commas, or labels from the value before calling the parser
- Prefer ParseFileDescriptorInformationFromKV when output is key/value formatted rather than positional
- Confirm the sysctl command/version produces the expected 3-field numeric layout
Example fix
// before raw := "10 0 1,024" // thousands separator info, err := ParseSysctlFileDescriptorInformation(raw) // after raw = strings.ReplaceAll(raw, ",", "") info, err := ParseSysctlFileDescriptorInformation(raw)
Defensive patterns
Strategy: validation
Validate before calling
fields := strings.Fields(out)
if len(fields) < 3 {
return fmt.Errorf("sysctl fd output too short: %q", out)
}
if _, err := strconv.ParseUint(fields[2], 10, 64); err != nil {
return fmt.Errorf("non-numeric max-files field %q", fields[2])
} Type guard
func hasValidUintField(out string, idx int) bool {
fields := strings.Fields(out)
if idx >= len(fields) { return false }
_, err := strconv.ParseUint(fields[idx], 10, 64)
return err == nil
} Try / catch
info, err := ParseSysctlFileDescriptorInformation(out)
if err != nil {
var numErr *strconv.NumError
if errors.As(err, &numErr) {
// fall back to key/value parser or degrade gracefully
return nil, nil
}
return nil, err
} Prevention
- Strip units (K/M) and thousands separators from numeric sysctl values before parsing
- Verify field positions (max is index 2) against actual output on each target OS
- Add table-driven tests with real sysctl samples per platform
- Prefer the KV parser for label-bearing output
When it happens
Trigger: Calling ParseSysctlFileDescriptorInformation where fields[2] is non-numeric or empty: truncated output, output with fewer tokens that happened to still be 3 but labeled (e.g. "10 open max"), values with units like "256K", or a comma-separated number "1,024".
Common situations: OS-version differences in sysctl output; locale-formatted numbers with thousands separators; capturing the wrong command output; cgroup/container environments reporting abbreviated limits.
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
- expected file descriptor information to have %d fields got %
- error parsing files current field '%s': %w
- parsing file descriptor information: %w, key=%s
- error parsing OriginCert: %v
- parsing memory information: %w, key=%s
AI-assisted analysis of cloudflare/cloudflared@2253eeeb25 (2026-09-06).
Data as JSON: /api/errors/df716c71649a5c32.
Report an issue: GitHub.