jackwener/OpenCLI · error · ArgumentError
maven groupId "${groupId}" is not a valid token
Error message
maven groupId "${groupId}" is not a valid token What it means
requireCoord() validates the groupId against COORD_TOKEN (letters/digits/._-, max 200 chars, must start with a letter or digit). This ArgumentError is thrown when the groupId contains other characters, is longer than 200 chars, or starts with '.', '_', or '-'.
Source
Thrown at clis/maven/utils.js:54
* groupId / artifactId are required; version is optional.
*/
export function requireCoord(value) {
const raw = String(value ?? '').trim();
if (!raw) {
throw new ArgumentError('maven coordinate is required (e.g. "com.fasterxml.jackson.core:jackson-databind")');
}
const parts = raw.split(':');
if (parts.length < 2 || parts.length > 3) {
throw new ArgumentError(
`maven coordinate "${value}" must be "groupId:artifactId" or "groupId:artifactId:version"`,
);
}
const [groupId, artifactId, version] = parts;
if (!groupId || !artifactId) {
throw new ArgumentError(`maven coordinate "${value}" is missing groupId or artifactId`);
}
if (groupId.length > 200 || !COORD_TOKEN.test(groupId)) {
throw new ArgumentError(
`maven groupId "${groupId}" is not a valid token`,
'Use letters / digits / "_-." (max 200 chars), starting with a letter or digit.',
);
}
if (artifactId.length > 200 || !COORD_TOKEN.test(artifactId)) {
throw new ArgumentError(
`maven artifactId "${artifactId}" is not a valid token`,
'Use letters / digits / "_-." (max 200 chars), starting with a letter or digit.',
);
}
if (version != null && version.length > 200) {
throw new ArgumentError(`maven version "${version}" is too long (max 200 chars).`);
}
return { groupId, artifactId, version: version ?? null };
}
export async function mavenFetch(url, label) {
let resp;View on GitHub (pinned to 49907e53dc)
Solutions
- Use a Java-package-style groupId: letters, digits, dots, underscores, hyphens only, e.g. 'com.google.guava'.
- Ensure the first character is a letter or digit (strip leading dots/dashes).
- Shorten the groupId to 200 characters or fewer.
- Decode any URL-encoded characters (%2F, %20) that leaked into the value.
Example fix
// before
requireCoord('https://repo1.maven.org/maven2/com/google/guava:guava');
// after
requireCoord('com.google.guava:guava'); Defensive patterns
Strategy: validation
Validate before calling
const COORD_TOKEN = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
function isValidGroupId(g) {
return typeof g === 'string' && g.length <= 200 && COORD_TOKEN.test(g);
}
if (!isValidGroupId(groupId)) throw new Error('invalid groupId'); Type guard
function isGroupIdToken(v) {
return typeof v === 'string' && v.length <= 200 && /^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(v);
} Try / catch
try {
requireCoord(input);
} catch (err) {
console.error(`${err.message} — ${err.hint ?? 'use letters/digits/_-. max 200 chars'}`);
} Prevention
- GroupIds look like reverse-DNS Java packages: letters, digits, dots, hyphens, underscores only.
- Never paste repo URLs or file paths as coordinates.
- Strip leading dots/dashes and URL-encoding from inputs.
- Keep the groupId under 200 characters.
When it happens
Trigger: Calling with a groupId containing illegal characters (spaces, '/', '@', ':', unicode), starting with a dot/underscore/hyphen, or exceeding 200 characters.
Common situations: Pasting a Maven repo URL path ('https://repo1.maven.org/maven2/org/...') as a coordinate; groupId with spaces from free-text input; reversed domain with typos like '.com.example'; file paths used as groupIds.
Related errors
- maven artifactId "${artifactId}" is not a valid token
- maven ${label} cannot be empty
- maven ${label} must be a positive integer
- maven ${label} must be <= ${maxValue}
- maven coordinate is required (e.g. "com.fasterxml.jackson.co
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/24ae2d488e72aefd.
Report an issue: GitHub.