{"record":{"id":"3b06d43849e80c28","repo":"kubernetes/kubernetes","slug":"q-s-q-did-not-match-any-rule","errorCode":null,"errorMessage":"%q %s %q did not match any rule","messagePattern":"%q (.+?) %q did not match any rule","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/import-boss/main.go","lineNumber":401,"sourceCode":"\t\t\t\tklog.V(6).Infof(\"selector %v matches %q\", rule.SelectorRegexp, imp)\n\n\t\t\t\tdisp := rule.Evaluate(imp)\n\t\t\t\tif disp == DepAllowed {\n\t\t\t\t\tdecided = true\n\t\t\t\t\tbreak // no further rules, next file\n\t\t\t\t} else if disp == DepForbidden {\n\t\t\t\t\terrs = append(errs, fmt.Errorf(\"%q %s %q is forbidden by %s\", pkg.PkgPath, relate(imp), imp, file.path))\n\t\t\t\t\tdecided = true\n\t\t\t\t\tbreak // no further rules, next file\n\t\t\t\t}\n\t\t\t}\n\t\t\tif decided {\n\t\t\t\tbreak // no further files, next import\n\t\t\t}\n\t\t}\n\t\tif matched && !decided {\n\t\t\tklog.V(5).Infof(\"%q %s %q did not match any rule\", pkg, relate(imp), imp)\n\t\t\terrs = append(errs, fmt.Errorf(\"%q %s %q did not match any rule\", pkg.PkgPath, relate(imp), imp))\n\t\t}\n\t}\n\n\tif len(errs) > 0 {\n\t\treturn errs\n\t}\n\n\treturn nil\n}\n\nfunc uniq(slices ...[]string) []string {\n\tm := map[string]bool{}\n\tfor _, sl := range slices {\n\t\tfor _, str := range sl {\n\t\t\tm[str] = true\n\t\t}\n\t}\n\tret := []string{}","sourceCodeStart":383,"sourceCodeEnd":419,"githubUrl":"https://github.com/kubernetes/kubernetes/blob/b882c60b4023bdf09264c2d5d30a2cadebc240fb/cmd/import-boss/main.go#L383-L419","documentation":"Emitted in verifyRules (main.go:399-401) when an import matched at least one rule's selectorRegexp (matched) but no rule produced a definitive DepAllowed or DepForbidden (!decided). Rule.Evaluate returned DepUnknown because the import matched neither any AllowedPrefixes nor any ForbiddenPrefixes (main.go:263-270). This is a rule-coverage gap: the selector targeted the import but the prefixes didn't classify it, so import-boss fails safe.","triggerScenarios":"A selectorRegexp matches an import path, but the rule's AllowedPrefixes/ForbiddenPrefixes don't cover that path. E.g. selector `k8s.io` matches `k8s.io/client-go`, but the rule only lists allowedPrefixes: [k8s.io/api] with no forbidden prefix, leaving client-go undecided.","commonSituations":"Adding a broad selector without covering all imports it sweeps in; renaming a package so it falls out of both prefix lists; a new import under an existing selector nobody classified.","solutions":["Inspect the named import: add it to AllowedPrefixes (if ok) or ForbiddenPrefixes (if not) of the matching rule.","Tighten the selectorRegexp so it only matches imports the prefixes can classify.","If the import shouldn't be governed at all, narrow the selector to exclude it."],"exampleFix":"# before -- selector matches client-go but neither prefix covers it\n- selectorRegexp: k8s[.]io\n  allowedPrefixes:\n    - k8s.io/api          # client-go matches selector, undecided -> error\n\n# after -- explicitly allow or forbid\n- selectorRegexp: k8s[.]io\n  allowedPrefixes:\n    - k8s.io/api\n    - k8s.io/client-go    # now decided DepAllowed","handlingStrategy":"validation","validationCode":"// Detect coverage gaps before import-boss fails: every import the selector\n// matches must hit an allowed or forbidden prefix.\nfor _, imp := range allImports {\n    if !ruleSel.MatchString(imp) { continue }\n    if rule.Evaluate(imp) == DepUnknown {\n        fmt.Printf(\"undecided import: %s\\n\", imp)\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["When adding a selectorRegexp, enumerate the imports it will match and ensure each is allowed or forbidden.","Avoid catch-all selectors (.*) without exhaustive prefix lists.","Treat 'did not match any rule' as a rule-design bug, not a code bug."],"tags":["go","import-boss","kubernetes","imports","config","linting"],"analyzedSha":"b882c60b4023bdf09264c2d5d30a2cadebc240fb","analyzedAt":"2026-08-07T04:07:48.144Z","schemaVersion":2},"datasetVersion":"2026-08-07T07:17:06.508Z"}