{"record":{"id":"c73c5aa2290ef750","repo":"golang/go","slug":"empty-entry-in-govcs","errorCode":null,"errorMessage":"empty entry in GOVCS","messagePattern":"empty entry in GOVCS","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/vcs/vcs.go","lineNumber":638,"sourceCode":"type govcsRule struct {\n\tpattern string\n\tallowed []string\n}\n\n// A govcsConfig is a full GOVCS configuration.\ntype govcsConfig []govcsRule\n\nfunc 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}","sourceCodeStart":620,"sourceCodeEnd":656,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/vcs/vcs.go#L620-L656","documentation":"The GOVCS environment variable is a comma-separated list of 'pattern:vcsList' rules. During parsing, each comma-separated entry is trimmed; if an entry is empty (from a trailing comma, leading comma, or double comma), it is rejected as invalid.","triggerScenarios":"GOVCS contains a stray comma: `GOVCS=public:git,,private:all` (double comma) or `GOVCS=public:git,` (trailing comma) or `GOVCS=,public:git` (leading comma).","commonSituations":"Shell variable construction with empty elements; copy-paste errors in GOVCS; CI config templating that leaves trailing commas.","solutions":["Inspect the full GOVCS value: `echo $GOVCS`","Remove stray/empty entries — every comma-separated item must be non-empty","Validate the GOVCS string before setting it (see validationCode)"],"exampleFix":"# before\nexport GOVCS=\"public:git,,private:all\"\n\n# after\nexport GOVCS=\"public:git,private:all\"","handlingStrategy":"validation","validationCode":"# Validate GOVCS for empty entries before running go commands\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)\"  # trim\n    if [ -z \"$entry\" ]; then\n      echo \"ERROR: empty entry in GOVCS (check for stray/double/trailing commas)\"\n    fi\n  done\nfi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always validate GOVCS in CI before running go commands","Avoid dynamically constructing GOVCS strings that may leave empty entries","Test GOVCS changes with `go env GOVCS` and a trial `go get`"],"tags":["vcs","config","govcs","validation"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}