Skip to content

fix(config): check scanner.Err() after handleIncludes loop#1356

Open
toller892 wants to merge 1 commit into
cloudprober:mainfrom
toller892:fix/handleIncludes-scanner-err
Open

fix(config): check scanner.Err() after handleIncludes loop#1356
toller892 wants to merge 1 commit into
cloudprober:mainfrom
toller892:fix/handleIncludes-scanner-err

Conversation

@toller892

Copy link
Copy Markdown

Description

handleIncludes in config/config.go uses a bufio.Scanner to iterate over config file lines, but never checks scanner.Err() after the scan loop. When a line exceeds bufio.MaxScanTokenSize (64KiB), the scanner silently stops — Scan() returns false and the remaining content is discarded with no error surfaced.

This affects machine-generated config files (e.g., output from .String() on ProberConfig) where all configuration is on a single line. Once the config grows past ~60 probes, the line exceeds 64KiB, the scanner stops, and Cloudprober starts with zero probes — with no error in the logs.

Fix

Add scanner.Err() check after the scan loop:

if err := scanner.Err(); err != nil {
    return "", fmt.Errorf("error reading config content: %w", err)
}

This surfaces the error (typically bufio.ErrTooLong) instead of silently producing an incomplete config.

Fixes #1355

bufio.Scanner silently stops when a token exceeds MaxScanTokenSize
(64KiB). handleIncludes never called scanner.Err() after the scan
loop, so lines longer than 64KiB were silently dropped — the config
was parsed as if those lines didn't exist, resulting in zero probes
with no error in the logs.

Fixes cloudprober#1355
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lines longer than 64KiB in a Cloudprober configuration file are silently ignored

1 participant