{"record":{"id":"0fd99d1b887231b1","repo":"jackwener/OpenCLI","slug":"maven-coordinate-is-required-e-g-com-fasterxml","errorCode":null,"errorMessage":"maven coordinate is required (e.g. \"com.fasterxml.jackson.core:jackson-databind\")","messagePattern":"maven coordinate is required \\(e\\.g\\. \"com\\.fasterxml\\.jackson\\.core:jackson-databind\"\\)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/maven/utils.js","lineNumber":41,"sourceCode":"    const raw = value ?? defaultValue;\n    const n = typeof raw === 'number' ? raw : Number(raw);\n    if (!Number.isInteger(n) || n <= 0) {\n        throw new ArgumentError(`maven ${label} must be a positive integer`);\n    }\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)) {","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/maven/utils.js#L23-L59","documentation":"`requireCoord` parses a Maven coordinate string `groupId:artifactId[:version]` and throws ArgumentError 'maven coordinate is required (e.g. \"com.fasterxml.jackson.core:jackson-databind\")' when the input is missing, null, or whitespace-only after trimming. The library requires an explicit coordinate for coordinate-based lookups (info/version resolution for groupId, artifactId, version).","triggerScenarios":"Calling a coordinate-based operation (e.g. artifact info) with no coordinate argument: `requireCoord(undefined)`, `requireCoord('')`, `requireCoord('   ')`, or `requireCoord(null)` — typically args.coord missing entirely.","commonSituations":"A CLI invocation omitted the positional coordinate argument; a config key mismatch means the value is read from the wrong field; an automation script builds the coordinate from variables that are empty; user ran the tool without supplying the groupId:artifactId.","solutions":["Pass a full coordinate string like 'com.fasterxml.jackson.core:jackson-databind' (or with version: 'com.fasterxml.jackson.core:jackson-databind:2.16.1')","Check the argument wiring: ensure the value is read from the correct CLI flag/config key and is non-empty","Validate the coordinate format before calling: exactly 2 or 3 colon-separated non-empty segments","If the coordinate is user-supplied, prompt or fail early with a usage message showing the expected format"],"exampleFix":"// before\nconst info = await mavenInfo({ coord: process.env.COORD }); // COORD unset -> ''\n// after\nif (!process.env.COORD) throw new Error('COORD must be set, e.g. com.fasterxml.jackson.core:jackson-databind');\nconst info = await mavenInfo({ coord: process.env.COORD });","handlingStrategy":"validation","validationCode":"function isValidCoord(v) {\n  const s = typeof v === 'string' ? v.trim() : '';\n  if (!s) return false;\n  const parts = s.split(':');\n  return parts.length === 2 || parts.length === 3;\n}\nif (!isValidCoord(args.coord)) throw new Error('coord required: groupId:artifactId[:version]');","typeGuard":"function isMavenCoord(v) { return typeof v === 'string' && /^[^:\\s]+:[^:\\s]+(:[^:\\s]+)?$/.test(v.trim()); }","tryCatchPattern":"try {\n  const info = await mavenInfo({ coord });\n} catch (err) {\n  if (err instanceof ArgumentError && /coordinate is required/.test(err.message)) {\n    console.error('Usage: maven info <groupId:artifactId[:version]>');\n    process.exitCode = 2;\n    return;\n  }\n  throw err;\n}","preventionTips":["Always supply the coordinate in groupId:artifactId[:version] form","Check CLI positional args / env vars for emptiness before invoking the library","Build coordinates programmatically from validated groupId/artifactId parts","Show a usage example in your tool's help text so users know the expected format"],"tags":["argument-error","maven","coordinate","input-validation"],"backgroundTag":"missing-required-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}