{"record":{"id":"8758af88df3837a8","repo":"golang/go","slug":"unreachable-pattern-in-govcs-q-after-q","errorCode":null,"errorMessage":"unreachable pattern in GOVCS: %q after %q","messagePattern":"unreachable pattern in GOVCS: %q after %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/vcs/vcs.go","lineNumber":655,"sourceCode":"\t\tif item == \"\" {\n\t\t\treturn nil, fmt.Errorf(\"empty entry in GOVCS\")\n\t\t}\n\t\tpattern, list, found := strings.Cut(item, \":\")\n\t\tif !found {\n\t\t\treturn nil, fmt.Errorf(\"malformed entry in GOVCS (missing colon): %q\", item)\n\t\t}\n\t\tpattern, list = strings.TrimSpace(pattern), strings.TrimSpace(list)\n\t\tif pattern == \"\" {\n\t\t\treturn nil, fmt.Errorf(\"empty pattern in GOVCS: %q\", item)\n\t\t}\n\t\tif list == \"\" {\n\t\t\treturn nil, fmt.Errorf(\"empty VCS list in GOVCS: %q\", item)\n\t\t}\n\t\tif search.IsRelativePath(pattern) {\n\t\t\treturn nil, fmt.Errorf(\"relative pattern not allowed in GOVCS: %q\", pattern)\n\t\t}\n\t\tif old := have[pattern]; old != \"\" {\n\t\t\treturn nil, fmt.Errorf(\"unreachable pattern in GOVCS: %q after %q\", item, old)\n\t\t}\n\t\thave[pattern] = item\n\t\tallowed := strings.Split(list, \"|\")\n\t\tfor i, a := range allowed {\n\t\t\ta = strings.TrimSpace(a)\n\t\t\tif a == \"\" {\n\t\t\t\treturn nil, fmt.Errorf(\"empty VCS name in GOVCS: %q\", item)\n\t\t\t}\n\t\t\tallowed[i] = a\n\t\t}\n\t\tcfg = append(cfg, govcsRule{pattern, allowed})\n\t}\n\treturn cfg, nil\n}\n\nfunc (c *govcsConfig) allow(path string, private bool, vcs string) bool {\n\tfor _, rule := range *c {\n\t\tmatch := false","sourceCodeStart":637,"sourceCodeEnd":673,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/vcs/vcs.go#L637-L673","documentation":"GOVCS rules are evaluated in order and the first match wins. If the same pattern appears twice, the second occurrence is unreachable because the first already matched every request for that pattern. The parser detects this duplicate and rejects it.","triggerScenarios":"GOVCS contains the same pattern twice: `GOVCS=public:git,public:hg` — the second 'public' rule is shadowed by the first.","commonSituations":"Appending to GOVCS without checking for existing entries; merging multiple config sources that both define the same pattern.","solutions":["Consolidate duplicate patterns into a single entry with a combined VCS list: `public:git|hg`","Remove the later duplicate entry","Review the full GOVCS value for repeated patterns"],"exampleFix":"# before: duplicate 'public' pattern\nexport GOVCS=\"public:git,public:hg\"\n\n# after: single entry with combined VCS list\nexport GOVCS=\"public:git|hg\"","handlingStrategy":"validation","validationCode":"# Check for duplicate GOVCS patterns\nGOVCS_VAL=\"${GOVCS:-}\"\nif [ -n \"$GOVCS_VAL\" ]; then\n  echo \"$GOVCS_VAL\" | tr ',' '\\n' | while IFS= read -r entry; do\n    echo \"$(echo \"${entry%%:*}\" | xargs)\"\n  done | sort | uniq -d | while read -r dup; do\n    [ -n \"$dup\" ] && echo \"ERROR: duplicate GOVCS pattern: $dup\"\n  done\nfi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Consolidate duplicate GOVCS patterns into one entry with a combined VCS list","Review GOVCS after merging config from multiple sources","Validate GOVCS for uniqueness in CI"],"tags":["vcs","config","govcs","validation"],"backgroundTag":null,"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}