{"record":{"id":"47f50cb2f861e566","repo":"hashicorp/nomad","slug":"failed-to-scan-s-v","errorCode":null,"errorMessage":"failed to scan %s: %v","messagePattern":"failed to scan (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"client/fingerprint/bridge_linux.go","lineNumber":124,"sourceCode":"}\n\nfunc (f *BridgeFingerprint) searchFile(module, filename string, re *regexp.Regexp) error {\n\tfile, err := os.Open(filename)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to open %s: %v\", filename, err)\n\t}\n\tdefer func() {\n\t\t_ = file.Close()\n\t}()\n\n\tscanner := bufio.NewScanner(file)\n\tfor scanner.Scan() {\n\t\tif re.MatchString(scanner.Text()) {\n\t\t\treturn nil // found the module!\n\t\t}\n\t}\n\tif err := scanner.Err(); err != nil {\n\t\treturn fmt.Errorf(\"failed to scan %s: %v\", filename, err)\n\t}\n\n\treturn fmt.Errorf(\"module %s not in %s\", module, filename)\n}\n","sourceCodeStart":106,"sourceCodeEnd":129,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/client/fingerprint/bridge_linux.go#L106-L129","documentation":"searchFile opened the kernel metadata file but bufio.Scanner returned a non-nil error while reading it (I/O error, or a line exceeding the scanner's 64KB token limit). Like the other bridge detect errors, it is accumulated into multierror and merely disables the bridge fingerprint. Rare in practice; most failures are the open or not-found cases instead.","triggerScenarios":"scanner.Err() non-nil during a scan of /proc/modules or /lib/modules/<ver>/modules.builtin|modules.dep - hardware/disk I/O errors reading procfs, or a single line longer than bufio.Scanner's default MaxScanTokenSize (64KB) in modules.dep.","commonSituations":"Extremely long modules.dep entries on kernels with heavy module dependency chains exceeding 64KB per line; transient I/O errors on degraded storage; unusual /proc configurations.","solutions":["Re-read the file manually ('cat /proc/modules', 'cat /lib/modules/$(uname -r)/modules.dep') to check for real I/O errors.","If it's a scanner token-size issue, this is a Nomad-side limitation - load the module ('modprobe bridge') so detect succeeds earlier via /sys/module or /proc/modules, or file/patch the scanner buffer size.","Check dmesg/storage health if the error recurs and indicates genuine read failures.","If bridge mode is not used, the warning can be ignored."],"exampleFix":"// before: scanner fails on a >64KB line\nscanner := bufio.NewScanner(file)\nscanner.Scan() // bufio.Scanner: token too long\n// after (upstream-style fix)\nscanner := bufio.NewScanner(file)\nscanner.Buffer(make([]byte, 0, 64*1024), 1024*1024) // allow 1MB lines","handlingStrategy":"fallback","validationCode":"// host-side preflight (shell): ensure files are readable and lines are sane\n// awk 'length($0) > 65536 { print FILENAME\": long line \"NR }' /lib/modules/$(uname -r)/modules.dep","typeGuard":null,"tryCatchPattern":"if err := scanner.Err(); err != nil {\n    // log and continue - detect() aggregates this and disables bridge mode gracefully\n    f.logger.Warn(\"failed scanning kernel module file\", \"file\", filename, \"error\", err)\n    return fmt.Errorf(\"failed to scan %s: %v\", filename, err)\n}","preventionTips":["Monitor storage health (dmesg, smartctl) if scan I/O errors recur.","If hitting 'token too long', load the module directly so detection succeeds before reaching that file.","Keep kernels/distro packages up to date; pathological modules.dep entries usually indicate odd custom kernels."],"tags":["fingerprint","linux","bufio-scanner","kernel-module"],"backgroundTag":"bufio-token-too-long","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}