jackwener/OpenCLI · error · ArgumentError

--note must be 300 characters or fewer for LinkedIn connecti

Error message

--note must be 300 characters or fewer for LinkedIn connection requests

What it means

clampNote enforces LinkedIn's 300-character limit on connection request notes. If the whitespace-normalized --note exceeds 300 characters it throws ArgumentError instead of silently truncating, since a silently cut note could change the intended message.

Source

Thrown at clis/linkedin/connect.js:83

        return '';
    }
}

function requireStringArg(args, key, label = key) {
    const value = normalizeWhitespace(args[key]);
    if (!value) throw new ArgumentError(`${label} is required`);
    return value;
}

function requireLinkedInProfileUrl(value, label) {
    const url = canonicalizeLinkedInProfileUrl(value);
    if (!url) throw new ArgumentError(`${label} must be an exact https://www.linkedin.com/in/<profile>/ URL`);
    return url;
}

function clampNote(note) {
    const value = normalizeWhitespace(note);
    if (value.length > 300) throw new ArgumentError('--note must be 300 characters or fewer for LinkedIn connection requests');
    return value;
}

function canonicalizeLinkedInInviteUrl(value) {
    try {
        const url = new URL(normalizeWhitespace(value), 'https://www.linkedin.com');
        if (url.protocol !== 'https:' || url.username || url.password || url.port || !isLinkedInHost(url.hostname)) return '';
        if (!/^\/preload\/custom-invite\/?$/i.test(url.pathname)) return '';
        url.hostname = 'www.linkedin.com';
        url.hash = '';
        if (!url.pathname.endsWith('/')) url.pathname += '/';
        return url.toString();
    }
    catch {
        return '';
    }
}

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Shorten the --note to 300 characters or fewer before running the command
  2. Count the note length in your wrapper (after whitespace trimming) and reject early
  3. Generate dynamic notes with a template that truncates or composes within the budget
  4. Omit --note entirely to send a note-less connection request

Example fix

// before
--note "Hi Jane, I really enjoyed ... (350 chars of text) ..."
// after
--note "Hi Jane, enjoyed your talk on X — would love to connect."
Defensive patterns

Strategy: validation

Validate before calling

const note = (args.note || '').trim();
if (note.length > 300) throw new Error(`--note is ${note.length} chars; max is 300`);

Type guard

function isWithinNoteLimit(note, max = 300) { return typeof note === 'string' && note.trim().length <= max; }

Try / catch

try { await runConnect(args); } catch (e) { if (String(e.message).includes('300 characters')) { console.error('Shorten --note to <= 300 chars'); } else { throw e; } }

Prevention

When it happens

Trigger: Passing --note with a message longer than 300 characters after whitespace normalization.

Common situations: Programmatically generating notes from templates without checking length; notes including personalized greetings that push past the limit; LinkedIn raising/lowering the limit in the UI while the library keeps 300.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/58fc1e7a36a435d8. Report an issue: GitHub.