{"record":{"id":"812c5f58a99cc380","repo":"jackwener/OpenCLI","slug":"maven-coordinate-value-must-be-groupid-artif","errorCode":null,"errorMessage":"maven coordinate \"${value}\" must be \"groupId:artifactId\" or \"groupId:artifactId:version\"","messagePattern":"maven coordinate \"(.+?)\" must be \"groupId:artifactId\" or \"groupId:artifactId:version\"","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/maven/utils.js","lineNumber":45,"sourceCode":"    }\n    if (n > maxValue) {\n        throw new ArgumentError(`maven ${label} must be <= ${maxValue}`);\n    }\n    return n;\n}\n\n/**\n * Parse a Maven coordinate `groupId:artifactId[:version]` into segments.\n * groupId / artifactId are required; version is optional.\n */\nexport function requireCoord(value) {\n    const raw = String(value ?? '').trim();\n    if (!raw) {\n        throw new ArgumentError('maven coordinate is required (e.g. \"com.fasterxml.jackson.core:jackson-databind\")');\n    }\n    const parts = raw.split(':');\n    if (parts.length < 2 || parts.length > 3) {\n        throw new ArgumentError(\n            `maven coordinate \"${value}\" must be \"groupId:artifactId\" or \"groupId:artifactId:version\"`,\n        );\n    }\n    const [groupId, artifactId, version] = parts;\n    if (!groupId || !artifactId) {\n        throw new ArgumentError(`maven coordinate \"${value}\" is missing groupId or artifactId`);\n    }\n    if (groupId.length > 200 || !COORD_TOKEN.test(groupId)) {\n        throw new ArgumentError(\n            `maven groupId \"${groupId}\" is not a valid token`,\n            'Use letters / digits / \"_-.\" (max 200 chars), starting with a letter or digit.',\n        );\n    }\n    if (artifactId.length > 200 || !COORD_TOKEN.test(artifactId)) {\n        throw new ArgumentError(\n            `maven artifactId \"${artifactId}\" is not a valid token`,\n            'Use letters / digits / \"_-.\" (max 200 chars), starting with a letter or digit.',\n        );","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/maven/utils.js#L27-L63","documentation":"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.","triggerScenarios":"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'.","commonSituations":"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.","solutions":["Include both groupId and artifactId separated by one colon, e.g. 'com.fasterxml.jackson.core:jackson-databind'.","Add version as a third segment if needed: 'com.fasterxml.jackson.core:jackson-databind:2.17.0'.","Remove extra segments such as classifier/packaging; this API only accepts 2 or 3 parts.","Trim stray whitespace and check for accidental duplicate '::' or copy/paste artifacts."],"exampleFix":"// before\nrequireCoord('jackson-databind');\n// after\nrequireCoord('com.fasterxml.jackson.core:jackson-databind');","handlingStrategy":"validation","validationCode":"function isValidCoordShape(v) {\n  const s = String(v ?? '').trim();\n  const parts = s.split(':');\n  return parts.length === 2 || parts.length === 3;\n}\nif (!isValidCoordShape(input)) throw new Error('use groupId:artifactId[:version]');","typeGuard":"function isCoordShape(v) {\n  return typeof v === 'string' && /^[^:\\s]+:[^:\\s]+(:[^:\\s]+)?$/.test(v.trim());\n}","tryCatchPattern":"try {\n  const { groupId, artifactId, version } = requireCoord(input);\n} catch (err) {\n  console.error(`Bad coordinate \"${input}\": use groupId:artifactId[:version]`);\n}","preventionTips":["Always pass full 'groupId:artifactId[:version]' coordinates, never bare artifact names.","Reject classifier/packaging segments before calling (keep to 2-3 colon parts).","Trim user input and validate the colon count with a regex first.","Keep coordinate strings in config free of copy/paste artifacts."],"tags":["argument-error","maven","input-validation","coordinate-format"],"backgroundTag":"maven-coordinate-format-invalid","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}