jackwener/OpenCLI · error · ArgumentError
goproxy module path is required (e.g. "github.com/gin-gonic/
Error message
goproxy module path is required (e.g. "github.com/gin-gonic/gin", "golang.org/x/net")
What it means
This ArgumentError is thrown by requireModulePath in clis/goproxy/utils.js:22 when the value coerced to a string and trimmed is empty. The goproxy adapter refuses to build a proxy.golang.org URL without a module path, since every GOPROXY endpoint (e.g. /github.com/org/repo/@v/list) is keyed on it.
Source
Thrown at clis/goproxy/utils.js:22
// and serves the GOPROXY protocol (`@latest`, `@v/list`, `@v/<ver>.info|mod|zip`).
// Spec: https://go.dev/ref/mod#goproxy-protocol
import { ArgumentError, CommandExecutionError, EmptyResultError } from '@jackwener/opencli/errors';
export const GOPROXY_BASE = 'https://proxy.golang.org';
const UA = 'opencli-goproxy-adapter (+https://github.com/jackwener/opencli)';
// Module paths look like host/path/...; conservative shape: at least one slash,
// host segment is alnum + dots, path segments are alnum + dashes/dots/underscores/slashes.
// We enforce at most 200 chars and reject characters that would need URL-escaping.
const MODULE_PATH = /^[A-Za-z0-9][A-Za-z0-9._\/-]{0,199}$/;
// Go semver tags include "v" prefix; we accept the GOPROXY canonical form.
const VERSION_TAG = /^v[0-9]+(\.[0-9]+)*([-+][A-Za-z0-9._-]+)?$/;
export function requireModulePath(value) {
const s = String(value ?? '').trim();
if (!s) {
throw new ArgumentError(
'goproxy module path is required (e.g. "github.com/gin-gonic/gin", "golang.org/x/net")',
'Use the canonical module path that appears in `go.mod`.',
);
}
if (!MODULE_PATH.test(s) || !s.includes('/')) {
throw new ArgumentError(
`goproxy module path "${value}" is not a recognised Go module path`,
'Module paths look like "github.com/<org>/<repo>" or "golang.org/x/<name>".',
);
}
return s;
}
export function requireVersionTag(value) {
const s = String(value ?? '').trim();
if (!s) throw new ArgumentError('goproxy --version cannot be empty');
if (!VERSION_TAG.test(s)) {
throw new ArgumentError(View on GitHub (pinned to 49907e53dc)
Solutions
- Pass the canonical module path exactly as it appears in go.mod, e.g. requireModulePath('github.com/gin-gonic/gin').
- Check CLI flags: the module argument is required; run `goproxy --help` and supply the missing flag.
- If the value comes from config/env, guard for empty string/undefined before calling modulePath().
Example fix
// before
const mods = await goproxyList(modulePath());
// after
const mods = await goproxyList(modulePath('github.com/gin-gonic/gin')); Defensive patterns
Strategy: validation
Validate before calling
function isValidModulePath(v) {
const s = String(v ?? '').trim();
return s.length > 0 && /^[A-Za-z0-9][A-Za-z0-9._\/-]{0,199}$/.test(s) && s.includes('/');
}
if (!isValidModulePath(input)) throw new Error('module path required'); Type guard
const isNonEmptyString = (v) => typeof v === 'string' && v.trim().length > 0;
Try / catch
try {
const mod = modulePath(input);
} catch (err) {
if (err instanceof ArgumentError && /module path is required/.test(err.message)) {
console.error('Usage: pass the module path from go.mod, e.g. github.com/org/repo');
} else throw err;
} Prevention
- Always pass the exact module directive value from go.mod.
- Mark the --module CLI flag as required so arg parsers reject its absence.
- Default empty env/config values to undefined (not '') so required-arg checks fire with a clear message.
When it happens
Trigger: Calling requireModulePath(undefined), requireModulePath(null), requireModulePath(''), requireModulePath(' '), or any value that String()/trim() collapses to empty — e.g. modulePath() called without a --module flag in the CLI.
Common situations: Forgetting the --module/--mod argument on the CLI command; a script passing an unset environment variable or empty config field; a wrapper function with a null default that propagates into modulePath().
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- goproxy module path "${value}" is not a recognised Go module
- goproxy --version cannot be empty
- goproxy --version "${value}" is not a valid Go semver tag
- goproxy ${label} must be a positive integer
- goproxy ${label} must be <= ${maxValue}
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/5b0f1ae95f6da195.
Report an issue: GitHub.