{"record":{"id":"0ac3a6719bb37ae7","repo":"jackwener/OpenCLI","slug":"label-is-required-0ac3a6","errorCode":null,"errorMessage":"${label} is required","messagePattern":"(.+?) is required","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/linkedin/connect.js","lineNumber":71,"sourceCode":"        if (url.protocol !== 'https:' || url.username || url.password || url.port || !isLinkedInHost(url.hostname)) return '';\n        const match = url.pathname.match(/^\\/in\\/([^/]+)\\/?$/i);\n        if (!match || !match[1]) return '';\n        // LinkedIn redirects country subdomains (ca./uk./...) to www.; normalize the\n        // host so an expected `ca.linkedin.com/in/x` matches the landed `www.linkedin.com/in/x`.\n        url.hostname = 'www.linkedin.com';\n        url.hash = '';\n        url.search = '';\n        if (!url.pathname.endsWith('/')) url.pathname += '/';\n        return url.toString();\n    }\n    catch {\n        return '';\n    }\n}\n\nfunction requireStringArg(args, key, label = key) {\n    const value = normalizeWhitespace(args[key]);\n    if (!value) throw new ArgumentError(`${label} is required`);\n    return value;\n}\n\nfunction requireLinkedInProfileUrl(value, label) {\n    const url = canonicalizeLinkedInProfileUrl(value);\n    if (!url) throw new ArgumentError(`${label} must be an exact https://www.linkedin.com/in/<profile>/ URL`);\n    return url;\n}\n\nfunction clampNote(note) {\n    const value = normalizeWhitespace(note);\n    if (value.length > 300) throw new ArgumentError('--note must be 300 characters or fewer for LinkedIn connection requests');\n    return value;\n}\n\nfunction canonicalizeLinkedInInviteUrl(value) {\n    try {\n        const url = new URL(normalizeWhitespace(value), 'https://www.linkedin.com');","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/linkedin/connect.js#L53-L89","documentation":"requireStringArg is the argument-validation helper for the linkedin connect command. It normalizes whitespace on the given CLI arg and throws ArgumentError when the resulting value is empty, ensuring required string options are present before any browser automation begins.","triggerScenarios":"Running the linkedin connect command without --profile-url, or with an empty/whitespace-only --profile-url or --expected-name value (both are declared required:true).","commonSituations":"Forgetting a required flag on the CLI; a shell script passing an empty variable; quoting mistakes yielding a whitespace-only value; YAML/JSON config driving the CLI with a missing key.","solutions":["Pass the missing flag, e.g. --profile-url https://www.linkedin.com/in/<profile>/ and --expected-name '<Full Name>'","Check the exact flag spelling (kebab-case) — unknown/misspelled flags fall through as undefined","Inspect the script/config that builds the command to confirm the variable is non-empty before invocation","Add an early check in your wrapper script that fails fast with a clear message when a required arg is blank"],"exampleFix":"// before\nnode cli.js linkedin connect --expected-name \"Jane Doe\"\n// after\nnode cli.js linkedin connect --profile-url \"https://www.linkedin.com/in/jane-doe/\" --expected-name \"Jane Doe\"","handlingStrategy":"validation","validationCode":"const profileUrl = (args['profile-url'] || '').trim();\nconst expectedName = (args['expected-name'] || '').trim();\nif (!profileUrl) throw new Error('--profile-url is required');\nif (!expectedName) throw new Error('--expected-name is required');","typeGuard":"function hasRequiredArgs(args) { return typeof args['profile-url'] === 'string' && args['profile-url'].trim().length > 0 && typeof args['expected-name'] === 'string' && args['expected-name'].trim().length > 0; }","tryCatchPattern":"try { await runConnect(args); } catch (e) { if (e instanceof ArgumentError) { console.error(`Missing argument: ${e.message}`); process.exitCode = 2; } else { throw e; } }","preventionTips":["Validate required flags in a wrapper script before invoking the CLI","Use exact kebab-case flag names shown in the command's args table","Avoid passing shell variables without checking they are non-empty","Fail fast in CI when required inputs are blank"],"tags":["cli","validation","arguments"],"backgroundTag":"missing-required-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}