cloudflare/cloudflared · error · ErrKeyNotFound
parsing file descriptor information: %w, key=%s
Error message
parsing file descriptor information: %w, key=%s
What it means
ParseFileDescriptorInformationFromKV scans colon-separated key/value output for the given file-descriptor maximum key. This error is returned when the requested key is absent from the parsed pairs, wrapped with ErrKeyNotFound. It indicates the output text does not contain a recognizable `<key>: <number>` entry for the maximum file-descriptor limit.
Source
Thrown at diagnostic/system_collector_utils.go:262
}
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 {
return nil, fmt.Errorf(
"parsing file descriptor information: %w, key=%s",
ErrKeyNotFound,
fileDescriptorMaximumKey,
)
}
fileDescriptorCurrent, exists := pairs[fileDescriptorCurrentKey]
if !exists {
return nil, fmt.Errorf(
"parsing file descriptor information: %w, key=%s",
ErrKeyNotFound,
fileDescriptorCurrentKey,
)
}
return &FileDescriptorInformation{fileDescriptorMaximum, fileDescriptorCurrent}, nil
}
View on GitHub (pinned to 2253eeeb25)
Solutions
- Print the raw output and confirm the exact key spelling, including case and spacing, matches what is passed as fileDescriptorMaximumKey
- Use the key constant/string the OS actually emits (e.g. "maxfiles" vs "open files")
- Handle empty output from the upstream command before parsing (check command exit status)
- If values may be non-numeric, provide a lenient mapper or sanitize the values first
Example fix
// before info, err := ParseFileDescriptorInformationFromKV(out, "MaxFiles", "OpenFiles") // after info, err := ParseFileDescriptorInformationFromKV(out, "maxfiles", "openfiles") // exact key emitted by the OS
Defensive patterns
Strategy: try-catch
Validate before calling
if !strings.Contains(out, maxKey+":") {
return fmt.Errorf("output %q missing key %q", out, maxKey)
} Try / catch
info, err := ParseFileDescriptorInformationFromKV(out, maxKey, curKey)
if err != nil {
if errors.Is(err, ErrKeyNotFound) {
// degrade: skip FD diagnostic or try alternate key set
return nil, nil
}
return nil, err
} Prevention
- Capture and store raw command output to diagnose key-mismatch issues
- Use the exact key strings emitted by the OS, ideally as shared constants
- Check command exit status and non-empty output before parsing
- Test parsing against real output samples from every supported platform
When it happens
Trigger: Calling ParseFileDescriptorInformationFromKV with an output string missing the max key: wrong key string (case/spacing mismatch), the command output changed format across OS versions, empty output, or output where values failed ParseUint and were dropped from the pairs map.
Common situations: macOS `ulimit -Hn`/launchctl output vs Linux `ulimit -n` wording differences; container runtimes omitting limits; querying the wrong sysctl key; trailing whitespace or tabs after the key name.
Related errors
- parsing memory information: %w, key=%s
- error parsing files current field '%s': %w
- expected file descriptor information to have %d fields got %
- error parsing files max field '%s': %w
- error parsing OriginCert: %v
AI-assisted analysis of cloudflare/cloudflared@2253eeeb25 (2026-09-06).
Data as JSON: /api/errors/1e44e89e41e67c37.
Report an issue: GitHub.