fix(config): check scanner.Err() after handleIncludes loop#1356
Open
toller892 wants to merge 1 commit into
Open
fix(config): check scanner.Err() after handleIncludes loop#1356toller892 wants to merge 1 commit into
toller892 wants to merge 1 commit into
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
handleIncludesinconfig/config.gouses abufio.Scannerto iterate over config file lines, but never checksscanner.Err()after the scan loop. When a line exceedsbufio.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()onProberConfig) 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:This surfaces the error (typically
bufio.ErrTooLong) instead of silently producing an incomplete config.Fixes #1355