{"record":{"id":"eb359f6d5be64dd5","repo":"golang/go","slug":"invalid-s-path-v-eb359f","errorCode":null,"errorMessage":"invalid %s path: %v","messagePattern":"invalid (.+?) path: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/workcmd/edit.go","lineNumber":297,"sourceCode":"func allowedVersionArg(arg string) bool {\n\treturn !modfile.MustQuote(arg)\n}\n\n// parsePathVersionOptional parses path[@version], using adj to\n// describe any errors.\nfunc parsePathVersionOptional(adj, arg string, allowDirPath bool) (path, version string, err error) {\n\tbefore, after, found, err := modload.ParsePathVersion(arg)\n\tif err != nil {\n\t\treturn \"\", \"\", err\n\t}\n\tif !found {\n\t\tpath = arg\n\t} else {\n\t\tpath, version = strings.TrimSpace(before), strings.TrimSpace(after)\n\t}\n\tif err := module.CheckImportPath(path); err != nil {\n\t\tif !allowDirPath || !modfile.IsDirectoryPath(path) {\n\t\t\treturn path, version, fmt.Errorf(\"invalid %s path: %v\", adj, err)\n\t\t}\n\t}\n\tif path != arg && !allowedVersionArg(version) {\n\t\treturn path, version, fmt.Errorf(\"invalid %s version: %q\", adj, version)\n\t}\n\treturn path, version, nil\n}\n\n// flagEditworkReplace implements the -replace flag.\nfunc flagEditworkReplace(arg string) {\n\tbefore, after, found := strings.Cut(arg, \"=\")\n\tif !found {\n\t\tbase.Fatalf(\"go: -replace=%s: need old[@v]=new[@w] (missing =)\", arg)\n\t}\n\told, new := strings.TrimSpace(before), strings.TrimSpace(after)\n\tif strings.HasPrefix(new, \">\") {\n\t\tbase.Fatalf(\"go: -replace=%s: separator between old and new is =, not =>\", arg)\n\t}","sourceCodeStart":279,"sourceCodeEnd":315,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/workcmd/edit.go#L279-L315","documentation":"Thrown by parsePathVersionOptional (used by `go work edit -dropuse`/`-replace`) when the module-path portion of an argument fails module.CheckImportPath and the caller did not allow directory paths (or the path is not a directory-shaped path). It surfaces the underlying import-path validation error.","triggerScenarios":"Run `go work edit -dropuse Bad-Path` or `-replace Bad-Path=foo@v1` where the path violates Go import-path rules (uppercase letters, spaces, leading dots, invalid characters, empty segments). CheckImportPath returns an error and parsePathVersionOptional wraps it.","commonSituations":"Typo in a module path; passing a local Windows path with backslashes; using a capitalized or spaced repository name; copy-pasting a URL instead of a module path; trailing slashes or double slashes.","solutions":["Correct the module path to match Go import-path rules (lowercase, no spaces, dot-separated).","For a local directory, ensure the path looks like a directory path (modfile.IsDirectoryPath) and the command allows it.","Strip a leading scheme/host if you pasted a full URL: use the import path component only.","Validate first: `go list -m <path>`."],"exampleFix":"# before\n// go work edit -dropuse GitHub.com/User/Mod\n\n# after\n// go work edit -dropuse github.com/user/mod","handlingStrategy":"validation","validationCode":"// Validate a module path before passing to `go work edit`\nif err := module.CheckImportPath(path); err != nil {\n    log.Fatalf(\"invalid module path %q: %v\", path, err)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use lowercase, dot-separated module paths.","Strip URL schemes/hosts from pasted URLs.","Test paths with `go list -m` first."],"tags":["go-toolchain","work","modules","validation","path"],"backgroundTag":null,"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:31:55.035Z"}