{"record":{"id":"a12edea9724693e6","repo":"kubernetes/kops","slug":"error-parsing-q-v","errorCode":null,"errorMessage":"error parsing %q: %v","messagePattern":"error parsing %q: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"dns-controller/pkg/dns/zonespec.go","lineNumber":68,"sourceCode":"type ZoneRules struct {\n\t// We don't use a map so we can support e.g. *.example.com later\n\tZones    []*ZoneSpec\n\tWildcard bool\n}\n\nfunc ParseZoneRules(zones []string) (*ZoneRules, error) {\n\tr := &ZoneRules{}\n\n\tfor _, s := range zones {\n\t\ts = strings.TrimSpace(s)\n\t\tif s == \"*\" || s == \"*/*\" {\n\t\t\tr.Wildcard = true\n\t\t\tcontinue\n\t\t}\n\n\t\tzoneSpec, err := ParseZoneSpec(s)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"error parsing %q: %v\", s, err)\n\t\t}\n\n\t\tr.Zones = append(r.Zones, zoneSpec)\n\t}\n\n\tif len(zones) == 0 {\n\t\tklog.Infof(\"No rules specified, will permit management of all zones\")\n\t\tr.Wildcard = true\n\t}\n\n\treturn r, nil\n}\n\n// MatchesExplicitly returns true if this matches an explicit rule (not a wildcard)\nfunc (r *ZoneRules) MatchesExplicitly(zone dnsprovider.Zone) bool {\n\tname := EnsureDotSuffix(zone.Name())\n\tid := zone.ID()\n","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/dns-controller/pkg/dns/zonespec.go#L50-L86","documentation":"ParseZoneRules wraps an error returned by ParseZoneSpec for an individual --zone argument, prefixing it with the offending string. ParseZoneSpec itself is very lenient (it splits on '/'), so this fires when the wrapped ParseZoneSpec returns an error — meaning the entry could not be converted into a ZoneSpec, effectively a malformed zone rule in the controller's --zone flags.","triggerScenarios":"main() calls ParseZoneRules(strings from --zone flags) and one of the strings causes ParseZoneSpec to error; also hit directly in unit tests (TestParseZoneRules) feeding malformed specs.","commonSituations":"Malformed --zone flag values (e.g. empty string or unexpected format) passed on the dns-controller command line; mis-templated flag values in manifests/Helm charts producing blank entries; typos like '/1234' with an empty name.","solutions":["Log/inspect the quoted string in the error to find the offending --zone value","Correct the flag value to a supported form: example.com, */ZONE_ID, or example.com/ZONE_ID","Trim whitespace / empty entries from the flag list before starting the controller","Add a unit test covering the malformed spec via TestParseZoneRules"],"exampleFix":"// before\n--zone=\"\" --zone=example.com\n// after\n--zone=example.com  # or */Z1234 or example.com/Z1234","handlingStrategy":"validation","validationCode":"// validate --zone flags before starting the controller\nfor _, z := range zoneFlags {\n    z = strings.TrimSpace(z)\n    if z == \"\" { return fmt.Errorf(\"empty --zone entry\") }\n    if strings.HasPrefix(z, \"/\") { return fmt.Errorf(\"invalid zone spec %q: missing name before '/'\", z) }\n    parts := strings.Split(z, \"/\")\n    if len(parts) > 2 { return fmt.Errorf(\"invalid zone spec %q: too many '/'\", z) }\n}","typeGuard":null,"tryCatchPattern":"rules, err := dns.ParseZoneRules(zones)\nif err != nil {\n    klog.Fatalf(\"invalid --zone flags: %v\", err) // error quotes the bad entry\n}","preventionTips":["Use only 'example.com', '*/ZONEID', or 'example.com/ZONEID' forms","Trim whitespace and drop empty entries from flag lists","Validate flags in a unit test mirroring your deployment manifest"],"tags":["dns","zone-rules","configuration","flag-parsing"],"backgroundTag":"zone-spec-parse-error","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}