{"record":{"id":"e56f434defd88bf2","repo":"golang/go","slug":"invalid-module-version-syntax-q","errorCode":null,"errorMessage":"invalid module version syntax %q","messagePattern":"invalid module version syntax %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/modget/query.go","lineNumber":148,"sourceCode":"\t// unlike the modules in pkgMods, this module does not inherently exclude\n\t// any other module in pkgMods.\n\tmod module.Version\n\n\terr error\n}\n\n// errSet returns a pathSet containing the given error.\nfunc errSet(err error) pathSet { return pathSet{err: err} }\n\n// newQuery returns a new query parsed from the raw argument,\n// which must be either path or path@version.\nfunc newQuery(ld *modload.Loader, raw string) (*query, error) {\n\tpattern, rawVers, found, err := modload.ParsePathVersion(raw)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif found && (strings.Contains(rawVers, \"@\") || rawVers == \"\") {\n\t\treturn nil, fmt.Errorf(\"invalid module version syntax %q\", raw)\n\t}\n\n\t// If no version suffix is specified, assume @upgrade.\n\t// If -u=patch was specified, assume @patch instead.\n\tversion := rawVers\n\tif version == \"\" {\n\t\tif getU.version == \"\" {\n\t\t\tversion = \"upgrade\"\n\t\t} else {\n\t\t\tversion = getU.version\n\t\t}\n\t}\n\n\tq := &query{\n\t\traw:            raw,\n\t\trawVersion:     rawVers,\n\t\tpattern:        pattern,\n\t\tpatternIsLocal: filepath.IsAbs(pattern) || search.IsRelativePath(pattern),","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/modget/query.go#L130-L166","documentation":"This error is thrown during query parsing in newQuery when ParsePathVersion finds an '@' separator (found=true) but the version portion either contains another '@' or is empty. For example, 'module@@1.0' has two @ signs, and 'module@' has an empty version. Both indicate malformed module version syntax.","triggerScenarios":"Parsing a 'go get' argument with the pattern path@version. ParsePathVersion splits on the first '@', returning the version suffix. If that suffix is empty (trailing @ with nothing after) or contains another @ (multiple @ signs), the syntax is invalid.","commonSituations":"A user types 'go get example.com/mymodule@' (trailing @ with no version). A user types 'go get example.com/mymodule@@v1.0' (double @). A script or CI pipeline constructs the argument incorrectly (e.g., concatenating module path with an empty version variable). A copy-paste error includes an extra @.","solutions":["Remove the trailing @ or specify a version: 'go get example.com/mymodule' or 'go get example.com/mymodule@latest'.","Ensure there's exactly one @ separator: 'go get example.com/mymodule@v1.2.0'.","Check scripts that construct go get arguments: ensure the version variable is non-empty before appending @version.","Use valid version keywords: 'go get example.com/mymodule@latest', '@upgrade', '@patch', or '@none'."],"exampleFix":"# before\n$ go get example.com/mymodule@\n# invalid module version syntax \"example.com/mymodule@\"\n\n# after\n$ go get example.com/mymodule@latest\n# or without version (defaults to @upgrade)\n$ go get example.com/mymodule","handlingStrategy":"validation","validationCode":"// Validate go get argument syntax before passing to go\nfunc validateGetArgSyntax(arg string) error {\n    atIdx := strings.Index(arg, \"@\")\n    if atIdx == -1 { return nil } // no @, fine\n    if atIdx == len(arg)-1 {\n        return fmt.Errorf(\"argument %q has trailing @ with no version\", arg)\n    }\n    versionPart := arg[atIdx+1:]\n    if strings.Contains(versionPart, \"@\") {\n        return fmt.Errorf(\"argument %q contains multiple @ signs\", arg)\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"if strings.Contains(stderr, \"invalid module version syntax\") {\n    // Malformed @version in the argument\n    // Suggest: check for trailing @ or double @@\n}","preventionTips":["Ensure go get arguments contain at most one @ separator","Never leave a trailing @ without a version specifier","Validate dynamically constructed arguments in scripts before passing to go get","Use known version keywords: @latest, @upgrade, @patch, @none, or @v1.2.3"],"tags":["go-get","go-modules","validation","argument-parsing"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}