{"record":{"id":"7917a643139474f5","repo":"prometheus/node_exporter","slug":"invalid-flag-value-q","errorCode":null,"errorMessage":"invalid flag value %q","messagePattern":"invalid flag value %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"collector/perf_linux.go","lineNumber":143,"sourceCode":"\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tcpus = append(cpus, cpu)\n\t\t\tcontinue\n\t\t}\n\n\t\tstride := 1\n\t\t// Handle strides, ie 1-10:5 should yield 1,5,10\n\t\tstrideSet := strings.Split(subset, \":\")\n\t\tif len(strideSet) == 2 {\n\t\t\tstride, err = strconv.Atoi(strideSet[1])\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t}\n\n\t\trangeSet := strings.Split(strideSet[0], \"-\")\n\t\tif len(rangeSet) != 2 {\n\t\t\treturn nil, fmt.Errorf(\"invalid flag value %q\", cpuFlag)\n\t\t}\n\t\tstart, err := strconv.Atoi(rangeSet[0])\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tend, err := strconv.Atoi(rangeSet[1])\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tfor i := start; i <= end; i += stride {\n\t\t\tcpus = append(cpus, i)\n\t\t}\n\t}\n\n\treturn cpus, nil\n}\n\n// perfTracepoint is a struct for holding tracepoint information.","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/prometheus/node_exporter/blob/17ddd77c59ba27e1508e9f7894b1e55b44d6aed3/collector/perf_linux.go#L125-L161","documentation":"perfCPUFlagToCPUs parses the --collector.perf.cpus flag, which accepts comma-separated CPU numbers, ranges (0-3), and strides (1-10:5). This error is thrown when a range element like \"0-3\" splits on \"-\" into something other than exactly two parts (e.g. \"0-\" , \"-3\", or a nested range like \"0-3-6\"). The library rejects the whole flag value rather than guessing the intended CPU set.","triggerScenarios":"Called from NewPerfCollector when --collector.perf.cpus contains a subset containing \"-\" whose first colon-stripped part does not split into exactly two dash-separated fields; e.g. \"0-\", \"-2\", \"0-3-6\", or trailing commas producing empty ranges.","commonSituations":"Typos in the flag value on the node_exporter command line, copy-pasting a CPU list from cpuset syntax (e.g. \"0-3,8-11\" written as \"0-3-8-11\"), or generating the flag from a script that emits empty range halves.","solutions":["Fix the --collector.perf.cpus value so every range is in the form START-END or START-END:STRIDE, e.g. \"0-3,8-11:2\".","If you want individual CPUs, list them without dashes: \"0,1,2\".","Validate the flag with a quick check that each dash-containing element has exactly one dash before the optional \":stride\" part."],"exampleFix":"// before\nnode_exporter --collector.perf.cpus=\"0-3-8\"\n// after\nnode_exporter --collector.perf.cpus=\"0-3,8\"","handlingStrategy":"validation","validationCode":"package main\n\nimport (\n\t\"fmt\"\n\t\"regexp\"\n)\n\nvar cpuFlagRe = regexp.MustCompile(`^\\d+(-\\d+(:\\d+)?)?(,\\d+(-\\d+(:\\d+)?)?)*$`)\n\nfunc validPerfCPUFlag(v string) error {\n\tif !cpuFlagRe.MatchString(v) {\n\t\treturn fmt.Errorf(\"invalid --collector.perf.cpus %q: ranges must be START-END[:STRIDE]\", v)\n\t}\n\treturn nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate the flag format before launching node_exporter in deployment scripts.","Use only canonical forms: single CPUs, START-END, or START-END:STRIDE separated by commas.","Avoid hand-editing generated flag strings; generate them programmatically and test with a dry run."],"tags":["go","cli-flag","parsing","node-exporter","perf"],"backgroundTag":"invalid-flag-value","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"}