{"record":{"id":"7396e56afc825d33","repo":"jackwener/OpenCLI","slug":"maven-artifactid-artifactid-is-not-a-valid-to","errorCode":null,"errorMessage":"maven artifactId \"${artifactId}\" is not a valid token","messagePattern":"maven artifactId \"(.+?)\" is not a valid token","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/maven/utils.js","lineNumber":60,"sourceCode":"    }\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}\n\nexport async function mavenFetch(url, label) {\n    let resp;\n    try {\n        resp = await fetch(url, { headers: { 'user-agent': UA, accept: 'application/json' } });\n    }\n    catch (err) {\n        throw new CommandExecutionError(\n            `${label} request failed: ${err?.message ?? err}`,","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/maven/utils.js#L42-L78","documentation":"requireCoord() validates the artifactId against the same COORD_TOKEN rule as groupId (letters/digits/._-, max 200 chars, must start with a letter or digit). This ArgumentError is thrown when the artifactId segment fails that pattern or is too long.","triggerScenarios":"Calling with an artifactId containing illegal characters (spaces, slashes, brackets), starting with '.', '_' or '-', or longer than 200 characters.","commonSituations":"Copy/pasting an artifact filename like 'guava-33.0.0-jre.jar' including '.jar' or path; version ranges or classifiers smuggled into the artifact segment ('a:b:1.0' typo'd as 'a:b-c:1.0' is fine, but 'a:/path' is not); whitespace from CSV/TSV input.","solutions":["Use a plain token artifactId, e.g. 'jackson-databind' — letters, digits, '_', '-', '.' only.","Strip file extensions and path components from the artifact name.","Ensure the artifactId starts with a letter or digit.","Keep it at or under 200 characters."],"exampleFix":"// before\nrequireCoord('com.google.guava:guava-33.0.0-jre.jar');\n// after\nrequireCoord('com.google.guava:guava');","handlingStrategy":"validation","validationCode":"const COORD_TOKEN = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;\nfunction isValidArtifactId(a) {\n  return typeof a === 'string' && a.length <= 200 && COORD_TOKEN.test(a);\n}\nif (!isValidArtifactId(artifactId)) throw new Error('invalid artifactId');","typeGuard":"function isArtifactIdToken(v) {\n  return typeof v === 'string' && v.length <= 200 && /^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(v);\n}","tryCatchPattern":"try {\n  requireCoord(input);\n} catch (err) {\n  console.error(`artifactId invalid: ${err.message}`);\n}","preventionTips":["Strip .jar extensions and paths from artifact names before use.","ArtifactId must start with a letter or digit — reject '.', '_', '-' starts early.","Validate from parsed segments, not the raw string, to catch the offending piece.","Keep whitespace out of CSV/TSV-derived inputs (trim each field)."],"tags":["argument-error","maven","input-validation","regex-validation"],"backgroundTag":"maven-coordinate-format-invalid","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}