{"record":{"id":"24ae2d488e72aefd","repo":"jackwener/OpenCLI","slug":"maven-groupid-groupid-is-not-a-valid-token","errorCode":null,"errorMessage":"maven groupId \"${groupId}\" is not a valid token","messagePattern":"maven groupId \"(.+?)\" is not a valid token","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/maven/utils.js","lineNumber":54,"sourceCode":" * 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}\n\nexport async function mavenFetch(url, label) {\n    let resp;","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/maven/utils.js#L36-L72","documentation":"requireCoord() validates the groupId against COORD_TOKEN (letters/digits/._-, max 200 chars, must start with a letter or digit). This ArgumentError is thrown when the groupId contains other characters, is longer than 200 chars, or starts with '.', '_', or '-'.","triggerScenarios":"Calling with a groupId containing illegal characters (spaces, '/', '@', ':', unicode), starting with a dot/underscore/hyphen, or exceeding 200 characters.","commonSituations":"Pasting a Maven repo URL path ('https://repo1.maven.org/maven2/org/...') as a coordinate; groupId with spaces from free-text input; reversed domain with typos like '.com.example'; file paths used as groupIds.","solutions":["Use a Java-package-style groupId: letters, digits, dots, underscores, hyphens only, e.g. 'com.google.guava'.","Ensure the first character is a letter or digit (strip leading dots/dashes).","Shorten the groupId to 200 characters or fewer.","Decode any URL-encoded characters (%2F, %20) that leaked into the value."],"exampleFix":"// before\nrequireCoord('https://repo1.maven.org/maven2/com/google/guava:guava');\n// after\nrequireCoord('com.google.guava:guava');","handlingStrategy":"validation","validationCode":"const COORD_TOKEN = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;\nfunction isValidGroupId(g) {\n  return typeof g === 'string' && g.length <= 200 && COORD_TOKEN.test(g);\n}\nif (!isValidGroupId(groupId)) throw new Error('invalid groupId');","typeGuard":"function isGroupIdToken(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(`${err.message} — ${err.hint ?? 'use letters/digits/_-. max 200 chars'}`);\n}","preventionTips":["GroupIds look like reverse-DNS Java packages: letters, digits, dots, hyphens, underscores only.","Never paste repo URLs or file paths as coordinates.","Strip leading dots/dashes and URL-encoding from inputs.","Keep the groupId under 200 characters."],"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-29T12:17:43.993Z"}