{"record":{"id":"4e228227e2903dc7","repo":"jackwener/OpenCLI","slug":"maven-coordinate-value-is-missing-groupid-or","errorCode":null,"errorMessage":"maven coordinate \"${value}\" is missing groupId or artifactId","messagePattern":"maven coordinate \"(.+?)\" is missing groupId or artifactId","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/maven/utils.js","lineNumber":51,"sourceCode":"\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        );\n    }\n    if (version != null && version.length > 200) {\n        throw new ArgumentError(`maven version \"${version}\" is too long (max 200 chars).`);\n    }\n    return { groupId, artifactId, version: version ?? null };\n}","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/maven/utils.js#L33-L69","documentation":"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 '::'.","triggerScenarios":"Calling with 'g:' , ':a', or '::' — a colon-delimited string where the leading or second segment is empty after the split.","commonSituations":"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).","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."],"exampleFix":"// before\nrequireCoord(':commons-lang3');\n// after\nrequireCoord('org.apache.commons:commons-lang3');","handlingStrategy":"validation","validationCode":"function hasAllSegments(v) {\n  const [g = '', a = '', ...rest] = String(v ?? '').trim().split(':');\n  return g.length > 0 && a.length > 0 && rest.length <= 1;\n}\nif (!hasAllSegments(input)) throw new Error('groupId and artifactId are required');","typeGuard":"function isNonEmptyCoord(v) {\n  const p = typeof v === 'string' ? v.trim().split(':') : [];\n  return p.length >= 2 && p.length <= 3 && p[0] !== '' && p[1] !== '';\n}","tryCatchPattern":"try {\n  requireCoord(cfg.mavenCoordinate);\n} catch (err) {\n  failWith(`Set mavenCoordinate as groupId:artifactId; got: \"${cfg.mavenCoordinate}\"`);\n}","preventionTips":["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."],"tags":["argument-error","maven","input-validation","missing-field"],"backgroundTag":"maven-coordinate-format-invalid","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}