{"record":{"id":"0a08cc00c0670216","repo":"golang/go","slug":"invalid-s-version-q","errorCode":null,"errorMessage":"invalid %s version: %q","messagePattern":"invalid (.+?) version: %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/modcmd/edit.go","lineNumber":385,"sourceCode":"// 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}\n\tif !strings.HasSuffix(arg, \"]\") {\n\t\treturn modfile.VersionInterval{}, fmt.Errorf(\"invalid version interval: %q\", arg)\n\t}","sourceCodeStart":367,"sourceCodeEnd":403,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/modcmd/edit.go#L367-L403","documentation":"`go mod edit` argument parsing: the argument contained `@version`, but the version fails `allowedVersionArg`. Valid versions are canonical semver (`v1.2.3`), pseudo-versions (`v1.2.3-0.20240101000000-abcdef123456`), or the special tokens `latest`, `upgrade`, `patch`. `adj` indicates which flag produced the argument.","triggerScenarios":"`go mod edit -require foo@1.0.0` (missing `v`); `go mod edit -require foo@v1` (incomplete semver); `go mod edit -require foo@randomstring`.","commonSituations":"Forgetting the `v` prefix; using a git tag that is not semver-shaped; passing a branch name instead of a version.","solutions":["Use a canonical semver tag with the `v` prefix, e.g. `v1.2.3`.","Use `latest` if you want the newest version resolved by the proxy.","For non-semver tags, derive the pseudo-version or retag the release with semver."],"exampleFix":"// before\ngo mod edit -require foo@1.0.0\n\n// after\ngo mod edit -require foo@v1.0.0","handlingStrategy":"validation","validationCode":"// Validate semver shape with the v prefix.\nfunc validVersion(v string) bool {\n    if v == \"latest\" || v == \"upgrade\" || v == \"patch\" { return true }\n    if !strings.HasPrefix(v, \"v\") { return false }\n    return semver.IsValid(v) // import \"golang.org/x/mod/semver\"\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always include the `v` prefix on semver versions.","Validate with `semver.IsValid` before scripting `go mod edit`.","Convert non-semver tags to pseudo-versions or retag with semver."],"tags":["go-toolchain","go-mod","version","mod-edit"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}