{"record":{"id":"458c1b9459681673","repo":"thanos-io/thanos","slug":"cidr-s","errorCode":null,"errorMessage":"cidr: %s","messagePattern":"cidr: %s","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cortex/util/flagext/cidr.go","lineNumber":57,"sourceCode":"\n// String implements flag.Value\nfunc (c CIDRSliceCSV) String() string {\n\tvalues := make([]string, 0, len(c))\n\tfor _, cidr := range c {\n\t\tvalues = append(values, cidr.String())\n\t}\n\n\treturn strings.Join(values, \",\")\n}\n\n// Set implements flag.Value\nfunc (c *CIDRSliceCSV) Set(s string) error {\n\tparts := strings.SplitSeq(s, \",\")\n\n\tfor part := range parts {\n\t\tcidr := &CIDR{}\n\t\tif err := cidr.Set(part); err != nil {\n\t\t\treturn errors.Wrapf(err, \"cidr: %s\", part)\n\t\t}\n\n\t\t*c = append(*c, *cidr)\n\t}\n\n\treturn nil\n}\n\n// UnmarshalYAML implements yaml.Unmarshaler.\nfunc (c *CIDRSliceCSV) UnmarshalYAML(unmarshal func(any) error) error {\n\tvar s string\n\tif err := unmarshal(&s); err != nil {\n\t\treturn err\n\t}\n\n\t// An empty string means no CIDRs has been configured.\n\tif s == \"\" {\n\t\t*c = nil","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/internal/cortex/util/flagext/cidr.go#L39-L75","documentation":"This error is produced by CIDRSliceCSV.Set when one comma-separated element of the input string fails to parse as a valid CIDR block. The underlying error from CIDR.Set (typically a net.ParseCIDR failure) is wrapped with the offending part so the developer can see exactly which field of the CSV value was invalid. It surfaces when parsing configuration flags or YAML (via UnmarshalYAML) that contains a list of CIDRs.","triggerScenarios":"Calling Set on a flag or unmarshalling YAML into CIDRSliceCSV where any comma-separated part is not a valid CIDR (e.g. '10.0.0.0/8,not-a-cidr', missing prefix like '10.0.0.1', or an IPv6/mask mismatch like '10.0.0.0/33').","commonSituations":"Typos in network prefixes in config files, using a bare IP without a /mask suffix, netmasks in dotted form (255.255.0.0) instead of prefix length, or copy-pasting an address list that includes whitespace or invalid entries.","solutions":["Fix the offending part shown in the wrapped message to be a valid CIDR, e.g. '10.0.0.0/8'","Ensure every element has a /prefix length; convert bare IPs by appending the correct mask (e.g. '/32' for a single IPv4 host)","Replace dotted netmasks with prefix lengths (255.255.0.0 -> /16)","Remove stray whitespace or empty segments from the comma-separated value"],"exampleFix":"// before\ncidr-ingest-urls: 10.0.0.1, 192.168.0.0/16\n// after\ncidr-ingest-urls: 10.0.0.1/32,192.168.0.0/16","handlingStrategy":"validation","validationCode":"for _, part := range strings.Split(input, \",\") {\n    if _, _, err := net.ParseCIDR(strings.TrimSpace(part)); err != nil {\n        return fmt.Errorf(\"invalid CIDR %q: %w\", part, err)\n    }\n}","typeGuard":null,"tryCatchPattern":"var cfg flagext.CIDRSliceCSV\nif err := cfg.Set(input); err != nil {\n    var wrapped string\n    if strings.Contains(err.Error(), \"cidr: \") {\n        wrapped = strings.SplitN(err.Error(), \"cidr: \", 2)[1]\n    }\n    return fmt.Errorf(\"bad CIDR config at element %q: %w\", wrapped, err)\n}","preventionTips":["Validate all CIDR entries with net.ParseCIDR before writing them into config files","Always include a /prefix length; never use bare IPs or dotted netmasks","Trim whitespace around CSV elements","Add config schema validation at startup so bad values fail fast with a clear message"],"tags":["cidr","configuration","parsing"],"backgroundTag":"invalid-argument-format","analyzedSha":"35b8b991177def87ed52dcf10f9b6d87f07282c8","analyzedAt":"2026-09-07T01:49:59.689Z","contentChangedAt":"2026-09-07T01:49:59.689Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}