{"record":{"id":"8f478db89394815e","repo":"golang/go","slug":"file-scheme-disallowed","errorCode":null,"errorMessage":"file scheme disallowed","messagePattern":"file scheme disallowed","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/vcs/vcs.go","lineNumber":1111,"sourceCode":"\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\" {\n\t\treturn errors.New(\"file scheme disallowed\")\n\t}\n\treturn nil\n}\n\nvar fetchGroup singleflight.Group\nvar (\n\tfetchCacheMu sync.Mutex\n\tfetchCache   = map[string]fetchResult{} // key is metaImportsForPrefix's importPrefix\n)\n\n// metaImportsForPrefix takes a package's root import path as declared in a <meta> tag\n// and returns its HTML discovery URL and the parsed metaImport lines\n// found on the page.\n//\n// The importPath is of the form \"golang.org/x/tools\".\n// It is an error if no imports are found.\n// url will still be valid if err != nil.\n// The returned url will be of the form \"https://golang.org/x/tools?go-get=1\"","sourceCodeStart":1093,"sourceCodeEnd":1129,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/vcs/vcs.go#L1093-L1129","documentation":"validateRepoRoot explicitly rejects the `file:` scheme. Remote module discovery via go-get must not resolve to a local file URL; local modules are handled through replace directives instead.","triggerScenarios":"A meta tag or import path resolves to a `file://...` repo root during dynamic discovery.","commonSituations":"Misconfigured vanity tags pointing at file URLs; attempting to treat a local checkout as a remotely-discoverable module.","solutions":["Use an https/git/ssh scheme for the repo root in the meta tag.","For local modules, add a `replace` directive pointing at the local path instead of relying on discovery."],"exampleFix":"// before\n<meta name=\"go-import\" content=\"example.com git file:///modules/lib\">\n\n// after (use replace instead)\n// go.mod: replace example.com/lib => ../lib","handlingStrategy":"fallback","validationCode":"// Block file:// roots in remote discovery; suggest replace.\nfunc rejectFileRoot(root string) error {\n    u, err := url.Parse(root)\n    if err != nil { return err }\n    if u.Scheme == \"file\" { return errors.New(\"use a replace directive for local modules\") }\n    return nil\n}","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Use `replace` directives for local modules instead of file:// URLs.","Reserve remote discovery for https/git/ssh schemes."],"tags":["vcs","validation","scheme","vanity-import"],"backgroundTag":null,"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}