{"record":{"id":"e6aefcbbf5c0d01a","repo":"jackwener/OpenCLI","slug":"goproxy-module-path-value-is-not-a-recognised","errorCode":null,"errorMessage":"goproxy module path \"${value}\" is not a recognised Go module path","messagePattern":"goproxy module path \"(.+?)\" is not a recognised Go module path","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/goproxy/utils.js","lineNumber":28,"sourceCode":"\n// Module paths look like host/path/...; conservative shape: at least one slash,\n// host segment is alnum + dots, path segments are alnum + dashes/dots/underscores/slashes.\n// We enforce at most 200 chars and reject characters that would need URL-escaping.\nconst MODULE_PATH = /^[A-Za-z0-9][A-Za-z0-9._\\/-]{0,199}$/;\n\n// Go semver tags include \"v\" prefix; we accept the GOPROXY canonical form.\nconst VERSION_TAG = /^v[0-9]+(\\.[0-9]+)*([-+][A-Za-z0-9._-]+)?$/;\n\nexport function requireModulePath(value) {\n    const s = String(value ?? '').trim();\n    if (!s) {\n        throw new ArgumentError(\n            'goproxy module path is required (e.g. \"github.com/gin-gonic/gin\", \"golang.org/x/net\")',\n            'Use the canonical module path that appears in `go.mod`.',\n        );\n    }\n    if (!MODULE_PATH.test(s) || !s.includes('/')) {\n        throw new ArgumentError(\n            `goproxy module path \"${value}\" is not a recognised Go module path`,\n            'Module paths look like \"github.com/<org>/<repo>\" or \"golang.org/x/<name>\".',\n        );\n    }\n    return s;\n}\n\nexport function requireVersionTag(value) {\n    const s = String(value ?? '').trim();\n    if (!s) throw new ArgumentError('goproxy --version cannot be empty');\n    if (!VERSION_TAG.test(s)) {\n        throw new ArgumentError(\n            `goproxy --version \"${value}\" is not a valid Go semver tag`,\n            'Use the GOPROXY canonical form like \"v1.2.3\" or \"v0.0.0-20240101010101-abcdef012345\".',\n        );\n    }\n    return s;\n}","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/goproxy/utils.js#L10-L46","documentation":"Thrown by requireModulePath when the value is non-empty but fails either the MODULE_PATH regex (/^[A-Za-z0-9][A-Za-z0-9._\\/-]{0,199}$/) or the must-contain-at-least-one-slash check at clis/goproxy/utils.js:27. The library enforces a conservative Go module path shape to avoid building malformed proxy.golang.org URLs.","triggerScenarios":"Passing values like 'gin', 'github.com' (no slash), 'my module' (space), a URL 'https://github.com/gin-gonic/gin', a path over 200 chars, or one starting with '/', '.', or '-'.","commonSituations":"Users pasting a browser URL instead of the module path; omitting the host segment ('gin-gonic/gin'); single-segment standard-library names like 'fmt'; shell quoting leaving stray characters or whitespace.","solutions":["Use the full host-qualified path from go.mod, e.g. 'github.com/gin-gonic/gin' or 'golang.org/x/net' — not a repo URL or short name.","Strip scheme/'www.' prefixes: 'https://github.com/org/repo' → 'github.com/org/repo'.","Check for stray characters (spaces, quotes) and length ≤ 200; the value must start with an alphanumeric character and contain at least one '/'.","Run `go list -m` in the project to get the exact canonical module path."],"exampleFix":"// before\nmodulePath('https://github.com/gin-gonic/gin');\n// after\nmodulePath('github.com/gin-gonic/gin');","handlingStrategy":"validation","validationCode":"const MODULE_PATH = /^[A-Za-z0-9][A-Za-z0-9._\\/-]{0,199}$/;\nfunction validateModulePath(v) {\n  const s = String(v ?? '').trim();\n  if (!MODULE_PATH.test(s) || !s.includes('/')) throw new Error(`not a Go module path: ${s}`);\n  return s;\n}\nvalidateModulePath(input);","typeGuard":"const looksLikeGoModule = (v) =>\n  typeof v === 'string' && v.includes('/') && /^[A-Za-z0-9][A-Za-z0-9._\\/-]{0,199}$/.test(v);","tryCatchPattern":"try {\n  const mod = modulePath(raw);\n} catch (err) {\n  if (err instanceof ArgumentError) {\n    console.error(`'${raw}' is not a Go module path — use host/org/repo form from go.mod`);\n    process.exitCode = 2;\n  } else throw err;\n}","preventionTips":["Never paste browser URLs; strip 'https://' and any trailing path beyond the module root.","Sanity-check with `go list -m` before scripting against the proxy.","Reject single-segment names early (a valid module path always contains at least one '/')."],"tags":["argument-error","input-validation","goproxy","go-modules"],"backgroundTag":"invalid-module-path","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}