{"record":{"id":"b3022e55b87c78d7","repo":"golang/go","slug":"invalid-s-path-v","errorCode":null,"errorMessage":"invalid %s path: %v","messagePattern":"invalid (.+?) path: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/modcmd/edit.go","lineNumber":382,"sourceCode":"}\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\tif allowDirPath && modfile.IsDirectoryPath(arg) {\n\t\treturn arg, \"\", nil\n\t}\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\treturn path, version, fmt.Errorf(\"invalid %s path: %v\", adj, err)\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// parseVersionInterval parses a single version like \"v1.2.3\" or a closed\n// interval like \"[v1.2.3,v1.4.5]\". Note that a single version has the same\n// representation as an interval with equal upper and lower bounds: both\n// Low and High are set.\nfunc parseVersionInterval(arg string) (modfile.VersionInterval, error) {\n\tif !strings.HasPrefix(arg, \"[\") {\n\t\tif !allowedVersionArg(arg) {\n\t\t\treturn modfile.VersionInterval{}, fmt.Errorf(\"invalid version: %q\", arg)\n\t\t}\n\t\treturn modfile.VersionInterval{Low: arg, High: arg}, nil\n\t}","sourceCodeStart":364,"sourceCodeEnd":400,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/modcmd/edit.go#L364-L400","documentation":"`go mod edit` argument parsing (`parsePathVersionOptional`): after splitting a `path@version` argument, the path portion fails `module.CheckImportPath`. Import paths must obey Go's rules (no spaces, lowercase alphanumerics, no leading dots, valid runes). `adj` labels which flag the argument is for (e.g. module/require/exclude).","triggerScenarios":"`go mod edit -require 'foo bar@v1.0.0'` (space in path); `go mod edit -replace 'foo!/bar'` (invalid rune); uppercase-first or leading-dot path.","commonSituations":"Typos, shell-quoting mistakes, invalid characters pasted from docs, mismatched case expectations.","solutions":["Correct the import path to match Go's import-path rules (lowercase, alphanumerics, `-`, `_`, `.`, `/`).","Quote shell arguments to avoid whitespace splitting.","Confirm the path against the module's published go.mod `module` directive."],"exampleFix":"// before\ngo mod edit -require 'foo bar@v1.0.0'\n\n// after\ngo mod edit -require 'foobar@v1.0.0'","handlingStrategy":"validation","validationCode":"// Validate import-path syntax before passing to `go mod edit`.\nfunc validImportPath(p string) error {\n    return module.CheckImportPath(p) // import \"golang.org/x/mod/module\"\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate paths with `module.CheckImportPath` before constructing `go mod edit` args.","Quote shell arguments to preserve path integrity.","Pull canonical paths from the source go.mod, not from memory."],"tags":["go-toolchain","go-mod","module-path","mod-edit"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T08:17:17.861Z"}