jackwener/OpenCLI · error · ArgumentError
maven coordinate "${value}" is missing groupId or artifactId
Error message
maven coordinate "${value}" is missing groupId or artifactId What it means
After splitting the coordinate on ':', requireCoord() checks that both the groupId and artifactId segments are non-empty. This ArgumentError is thrown when either segment is an empty string, e.g. ':artifactId', 'groupId:', or '::'.
Source
Thrown at clis/maven/utils.js:51
/**
* Parse a Maven coordinate `groupId:artifactId[:version]` into segments.
* 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 };
}View on GitHub (pinned to 49907e53dc)
Solutions
- Provide a non-empty groupId before the first colon, e.g. 'org.apache.commons:commons-lang3'.
- Provide a non-empty artifactId after the first colon.
- Check the source of the value — an unset env var or config field is producing an empty segment.
- Use the full documented form 'groupId:artifactId[:version]' with no empty slots.
Example fix
// before
requireCoord(':commons-lang3');
// after
requireCoord('org.apache.commons:commons-lang3'); Defensive patterns
Strategy: validation
Validate before calling
function hasAllSegments(v) {
const [g = '', a = '', ...rest] = String(v ?? '').trim().split(':');
return g.length > 0 && a.length > 0 && rest.length <= 1;
}
if (!hasAllSegments(input)) throw new Error('groupId and artifactId are required'); Type guard
function isNonEmptyCoord(v) {
const p = typeof v === 'string' ? v.trim().split(':') : [];
return p.length >= 2 && p.length <= 3 && p[0] !== '' && p[1] !== '';
} Try / catch
try {
requireCoord(cfg.mavenCoordinate);
} catch (err) {
failWith(`Set mavenCoordinate as groupId:artifactId; got: "${cfg.mavenCoordinate}"`);
} Prevention
- Check config/env interpolation — empty placeholders create empty segments.
- Never build coordinates by joining possibly-undefined parts without filtering empties.
- Validate before calling: split on ':' and assert both first segments are non-empty.
- Avoid '::' typos when editing coordinates by hand.
When it happens
Trigger: Calling with 'g:' , ':a', or '::' — a colon-delimited string where the leading or second segment is empty after the split.
Common situations: Template/variable interpolation left a placeholder empty ('${group}:artifact'); truncated copy/paste that dropped the group; string built by joining parts where one was undefined producing 'undefined' or empty segments (note 'undefined' text would fail later token validation instead).
Related errors
- 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
- maven coordinate "${value}" must be "groupId:artifactId" or
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/4e228227e2903dc7.
Report an issue: GitHub.