{"record":{"id":"47e8693323cb994a","repo":"golang/go","slug":"leading-slash","errorCode":null,"errorMessage":"leading slash","messagePattern":"leading slash","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/vcs/vcs.go","lineNumber":1092,"sourceCode":"\trr := &RepoRoot{\n\t\tRepo:     repoURL,\n\t\tRoot:     mmi.Prefix,\n\t\tSubDir:   mmi.SubDir,\n\t\tIsCustom: true,\n\t\tVCS:      vcs,\n\t}\n\treturn rr, nil\n}\n\n// validateRepoSubDir returns an error if subdir is not a valid subdirectory path.\n// We consider a subdirectory path to be valid as long as it doesn't have a leading\n// slash (/) or hyphen (-).\nfunc validateRepoSubDir(subdir string) error {\n\tif subdir == \"\" {\n\t\treturn nil\n\t}\n\tif subdir[0] == '/' {\n\t\treturn errors.New(\"leading slash\")\n\t}\n\tif subdir[0] == '-' {\n\t\treturn errors.New(\"leading hyphen\")\n\t}\n\treturn nil\n}\n\n// validateRepoRoot returns an error if repoRoot does not seem to be\n// a valid URL with scheme.\nfunc validateRepoRoot(repoRoot string) error {\n\turl, err := urlpkg.Parse(repoRoot)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif url.Scheme == \"\" {\n\t\treturn errors.New(\"no scheme\")\n\t}\n\tif url.Scheme == \"file\" {","sourceCodeStart":1074,"sourceCodeEnd":1110,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/vcs/vcs.go#L1074-L1110","documentation":"validateRepoSubDir rejects a repository subdirectory that begins with `/`. Subdirs are expected to be relative paths within the repo; a leading slash would resolve outside the intended tree.","triggerScenarios":"A vanity-import meta tag (or VCS path config) supplies a subdir like `/cmd/foo` instead of `cmd/foo`.","commonSituations":"Misconfigured `<meta name=\"go-import\">`/`go-source` tags; hand-written vanity servers.","solutions":["Fix the meta tag / vanity server to emit a relative subdir (no leading slash).","Drop the subdir component entirely if the repo root is correct."],"exampleFix":"<!-- before -->\n<meta name=\"go-import\" content=\"example.com/git /sub/pkg git+ssh://...\">\n<!-- after -->\n<meta name=\"go-import\" content=\"example.com git+ssh://...\">","handlingStrategy":"validation","validationCode":"// Validate a vanity subdir before publishing meta tags.\nfunc validSubdir(s string) error {\n    if strings.HasPrefix(s, \"/\") { return errors.New(\"subdir must be relative\") }\n    return nil\n}","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Emit relative subdirs in go-import/go-source meta tags.","Test vanity paths with `go get -v` after deploying tags."],"tags":["vcs","validation","vanity-import"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T08:17:17.861Z"}