{"record":{"id":"57b121c8bf89dc3b","repo":"prometheus/node_exporter","slug":"fail-to-compile-collector-cpu-info-flags-include","errorCode":null,"errorMessage":"fail to compile --collector.cpu.info.flags-include and --collector.cpu.info.bugs-include, the values of them must be regular expressions: %w","messagePattern":"fail to compile --collector\\.cpu\\.info\\.flags-include and --collector\\.cpu\\.info\\.bugs-include, the values of them must be regular expressions: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"collector/cpu_linux.go","lineNumber":148,"sourceCode":"\t\t\t[]string{\"package\"}, nil,\n\t\t),\n\t\tcpuIsolated: prometheus.NewDesc(\n\t\t\tprometheus.BuildFQName(namespace, cpuCollectorSubsystem, \"isolated\"),\n\t\t\t\"Whether each core is isolated, information from /sys/devices/system/cpu/isolated.\",\n\t\t\t[]string{\"cpu\"}, nil,\n\t\t),\n\t\tcpuOnline: prometheus.NewDesc(\n\t\t\tprometheus.BuildFQName(namespace, cpuCollectorSubsystem, \"online\"),\n\t\t\t\"CPUs that are online and being scheduled.\",\n\t\t\t[]string{\"cpu\"}, nil,\n\t\t),\n\t\tlogger:       logger,\n\t\tisolatedCpus: isolcpus,\n\t\tcpuStats:     make(map[int64]procfs.CPUStat),\n\t}\n\terr = c.compileIncludeFlags(flagsInclude, bugsInclude)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"fail to compile --collector.cpu.info.flags-include and --collector.cpu.info.bugs-include, the values of them must be regular expressions: %w\", err)\n\t}\n\treturn c, nil\n}\n\nfunc (c *cpuCollector) compileIncludeFlags(flagsIncludeFlag, bugsIncludeFlag *string) error {\n\tif (*flagsIncludeFlag != \"\" || *bugsIncludeFlag != \"\") && !*enableCPUInfo {\n\t\t*enableCPUInfo = true\n\t\tc.logger.Info(\"--collector.cpu.info has been set to `true` because you set the following flags, like --collector.cpu.info.flags-include and --collector.cpu.info.bugs-include\")\n\t}\n\n\tvar err error\n\tif *flagsIncludeFlag != \"\" {\n\t\tc.cpuFlagsIncludeRegexp, err = regexp.Compile(*flagsIncludeFlag)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\tif *bugsIncludeFlag != \"\" {","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/prometheus/node_exporter/blob/17ddd77c59ba27e1508e9f7894b1e55b44d6aed3/collector/cpu_linux.go#L130-L166","documentation":"When --collector.cpu.info is enabled, the cpu collector compiles the --collector.cpu.info.flags-include and --collector.cpu.info.bugs-include values as regular expressions used to filter reported CPU flags/bugs. If either value is not a valid Go regexp, compilation fails at collector construction and node_exporter exits with this wrapped error.","triggerScenarios":"compileIncludeFlags returns an error because flagsInclude or bugsInclude contains invalid regexp syntax (e.g. unbalanced parentheses, bad escape sequences like \\p{x} or stray '*').","commonSituations":"Operators paste shell glob patterns (e.g. 'avx*') or fragmented regexes into the flags; quoting issues in systemd units strip backslashes; using PCRE-only syntax unsupported by Go's RE2 (e.g. lookaheads).","solutions":["Validate the expressions with Go regexp syntax (test with `go` or any RE2-compatible checker) and fix the syntax","Remember these are regexes, not globs: use 'avx.*' not 'avx*'","Escape properly in your shell/systemd unit (double backslashes where needed)","Unset the flags or disable --collector.cpu.info if filtering is not required"],"exampleFix":"// before\n--collector.cpu.info.flags-include='avx*'       // glob, invalid regex\n// after\n--collector.cpu.info.flags-include='^avx.*$'","handlingStrategy":"validation","validationCode":"// Go: validate the flags like the collector does, before launching\nimport \"regexp\"\nfunc validRE(s string) bool {\n    if s == \"\" { return true }\n    _, err := regexp.Compile(s)\n    return err == nil\n}\n// usage: if !validRE(*flagsInclude) || !validRE(*bugsInclude) { flag.Usage(); os.Exit(2) }","typeGuard":null,"tryCatchPattern":"if err := startExporter(args); err != nil && strings.Contains(err.Error(), \"must be regular expressions\") {\n    return fmt.Errorf(\"fix --collector.cpu.info.flags-include/--bugs-include (RE2 syntax): %w\", err)\n}","preventionTips":["Test the regex with RE2 (Go regexp) before deploying — no lookaheads/backreferences","Remember flags are regexes, not globs: '^avx.*$' not 'avx*','Mind shell/systemd quoting of backslashes in regexes"],"tags":["cpu","regex","cli-flags"],"backgroundTag":"invalid-regex-pattern","analyzedSha":"17ddd77c59ba27e1508e9f7894b1e55b44d6aed3","analyzedAt":"2026-09-07T17:54:06.211Z","contentChangedAt":"2026-09-07T17:54:06.211Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}