{"record":{"id":"8c0a01888cb2709c","repo":"golang/go","slug":"empty-pattern-in-govcs-q","errorCode":null,"errorMessage":"empty pattern in GOVCS: %q","messagePattern":"empty pattern in GOVCS: %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/vcs/vcs.go","lineNumber":646,"sourceCode":"func parseGOVCS(s string) (govcsConfig, error) {\n\ts = strings.TrimSpace(s)\n\tif s == \"\" {\n\t\treturn nil, nil\n\t}\n\tvar cfg govcsConfig\n\thave := make(map[string]string)\n\tfor item := range strings.SplitSeq(s, \",\") {\n\t\titem = strings.TrimSpace(item)\n\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","sourceCodeStart":628,"sourceCodeEnd":664,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/vcs/vcs.go#L628-L664","documentation":"After splitting a GOVCS entry on ':', the pattern portion (left of the colon) is empty after trimming whitespace — e.g., `:git` or `   :git`.","triggerScenarios":"GOVCS entry with no pattern before the colon: `GOVCS=:git,public:hg` or `GOVCS= :fossil`.","commonSituations":"Typo leaving pattern blank; shell variable expansion that yields an empty pattern.","solutions":["Ensure every entry has a non-empty pattern before the colon","Valid patterns are module path prefixes like 'github.com', 'example.com', 'public', 'private'","Inspect each entry: every item must look like `nonemptypattern:vcslist`"],"exampleFix":"# before\nexport GOVCS=\":git\"\n\n# after\nexport GOVCS=\"public:git\"","handlingStrategy":"validation","validationCode":"# Validate GOVCS entries have non-empty patterns\nGOVCS_VAL=\"${GOVCS:-}\"\nif [ -n \"$GOVCS_VAL\" ]; then\n  echo \"$GOVCS_VAL\" | tr ',' '\\n' | while IFS= read -r entry; do\n    entry=\"$(echo \"$entry\" | xargs)\"\n    pattern=\"${entry%%:*}\"\n    pattern=\"$(echo \"$pattern\" | xargs)\"\n    if [ -n \"$entry\" ] && echo \"$entry\" | grep -q ':' && [ -z \"$pattern\" ]; then\n      echo \"ERROR: empty pattern in GOVCS entry: $entry\"\n    fi\n  done\nfi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Every GOVCS entry must have a non-empty pattern before the colon","Use module-path-style patterns: github.com, example.com, public, private","Validate GOVCS configuration in CI"],"tags":["vcs","config","govcs","validation"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}