jackwener/OpenCLI · error · ArgumentError
goproxy --version cannot be empty
Error message
goproxy --version cannot be empty
What it means
Thrown by requireVersionTag at clis/goproxy/utils.js:38 when the --version value is missing or empty after trimming. The adapter needs a concrete Go semver tag to hit endpoints like @v/<ver>.info, so an empty version is rejected immediately.
Source
Thrown at clis/goproxy/utils.js:38
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(
`goproxy --version "${value}" is not a valid Go semver tag`,
'Use the GOPROXY canonical form like "v1.2.3" or "v0.0.0-20240101010101-abcdef012345".',
);
}
return s;
}
export function requireBoundedInt(value, defaultValue, maxValue, label = 'limit') {
const raw = value ?? defaultValue;
const n = typeof raw === 'number' ? raw : Number(raw);
if (!Number.isInteger(n) || n <= 0) {
throw new ArgumentError(`goproxy ${label} must be a positive integer`);
}
if (n > maxValue) {
throw new ArgumentError(`goproxy ${label} must be <= ${maxValue}`);
}View on GitHub (pinned to 49907e53dc)
Solutions
- Supply a concrete tag like 'v1.2.3' — check the repo's tags with `git tag -l` or `go list -m -versions <module>`.
- If you want the newest release, omit the version filter rather than passing an empty value, so the adapter can query @latest.
- Guard variables in scripts: fail early with a clear message if $VERSION is empty.
Example fix
// before const info = await goproxyVersionInfo(mod, process.env.VERSION); // after const tag = process.env.VERSION || 'v1.9.1'; const info = await goproxyVersionInfo(mod, requireVersionTag(tag));
Defensive patterns
Strategy: validation
Validate before calling
if (!process.env.VERSION || !process.env.VERSION.trim()) {
throw new Error('--version is required, e.g. --version v1.2.3');
} Type guard
const hasVersion = (v) => v != null && String(v).trim() !== '';
Try / catch
try {
const tag = requireVersionTag(flagValue);
} catch (err) {
if (err instanceof ArgumentError && /cannot be empty/.test(err.message)) {
console.error('Provide a version tag, e.g. --version v1.2.3');
} else throw err;
} Prevention
- Use ${VAR:?} shell expansions to fail fast on unset version variables.
- Make --version required in your CLI argument parser when a specific version is needed.
- Omit the version filter entirely when you actually want the latest release.
When it happens
Trigger: Calling requireVersionTag(''), requireVersionTag(undefined/null), or the CLI invoked with --version given no value; a config lookup returning an empty string.
Common situations: Scripting with an unset variable (e.g. $VERSION empty); forgetting the flag value (`goproxy --version` with nothing after it); a build tool emitting an empty tag field.
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 --version "${value}" is not a valid Go semver tag
- goproxy module path is required (e.g. "github.com/gin-gonic/
- goproxy module path "${value}" is not a recognised Go module
- 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/2ffdb9549ee7cdfc.
Report an issue: GitHub.