jackwener/OpenCLI · error · ArgumentError

maven coordinate "${value}" must be "groupId:artifactId" or

Error message

maven coordinate "${value}" must be "groupId:artifactId" or "groupId:artifactId:version"

What it means

requireCoord() parses a Maven coordinate string into {groupId, artifactId, version}. This ArgumentError is thrown when the string does not split into exactly 2 or 3 colon-separated segments, i.e. it is not 'groupId:artifactId' or 'groupId:artifactId:version'. The library enforces the canonical Maven coordinate shape before querying search.maven.org.

Source

Thrown at clis/maven/utils.js:45

    }
    if (n > maxValue) {
        throw new ArgumentError(`maven ${label} must be <= ${maxValue}`);
    }
    return n;
}

/**
 * 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.',
        );

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Include both groupId and artifactId separated by one colon, e.g. 'com.fasterxml.jackson.core:jackson-databind'.
  2. Add version as a third segment if needed: 'com.fasterxml.jackson.core:jackson-databind:2.17.0'.
  3. Remove extra segments such as classifier/packaging; this API only accepts 2 or 3 parts.
  4. Trim stray whitespace and check for accidental duplicate '::' or copy/paste artifacts.

Example fix

// before
requireCoord('jackson-databind');
// after
requireCoord('com.fasterxml.jackson.core:jackson-databind');
Defensive patterns

Strategy: validation

Validate before calling

function isValidCoordShape(v) {
  const s = String(v ?? '').trim();
  const parts = s.split(':');
  return parts.length === 2 || parts.length === 3;
}
if (!isValidCoordShape(input)) throw new Error('use groupId:artifactId[:version]');

Type guard

function isCoordShape(v) {
  return typeof v === 'string' && /^[^:\s]+:[^:\s]+(:[^:\s]+)?$/.test(v.trim());
}

Try / catch

try {
  const { groupId, artifactId, version } = requireCoord(input);
} catch (err) {
  console.error(`Bad coordinate "${input}": use groupId:artifactId[:version]`);
}

Prevention

When it happens

Trigger: Calling any maven command/tool with a coordinate argument containing 0, 1, or 4+ colon segments, e.g. 'jackson-databind' (no colon) or 'g:a:v:classifier'.

Common situations: Passing a bare artifactId instead of a full coordinate; pasting a Gradle dependency with a classifier or packaging suffix ('g:a:jar:1.0'); typos with extra colons; passing a URL or GAV string from another format.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/812c5f58a99cc380. Report an issue: GitHub.