jackwener/OpenCLI · error · ArgumentError
--body must be 1900 characters or fewer
Error message
--body must be 1900 characters or fewer
What it means
buildCreateMessagePayload enforces a maximum body length of 1900 characters (after trimming) to stay within Sales Navigator message limits; longer bodies throw ArgumentError before the API call.
Source
Thrown at clis/linkedin/salesnav-message.js:95
return `https://www.linkedin.com/sales-api/salesApiProfiles/${key}?decoration=${encodeRestliDecoration(PROFILE_DECO)}`;
}
function randomTrackingId() {
const bytes = new Uint8Array(8);
if (globalThis.crypto?.getRandomValues) globalThis.crypto.getRandomValues(bytes);
else for (let i = 0; i < bytes.length; i += 1) bytes[i] = Math.floor(Math.random() * 256);
return Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');
}
function buildCreateMessagePayload({ recipientUrn, subject, body, trackingId = randomTrackingId(), copyToCrm = false }) {
const cleanRecipient = normalizeWhitespace(recipientUrn);
if (!parseSalesProfileUrn(cleanRecipient)) throw new ArgumentError('--recipient must resolve to a Sales Navigator lead urn');
const cleanSubject = normalizeWhitespace(subject);
const cleanBody = String(body ?? '').trim();
if (!cleanSubject) throw new ArgumentError('--subject is required');
if (!cleanBody) throw new ArgumentError('--body is required');
if (cleanSubject.length > 200) throw new ArgumentError('--subject must be 200 characters or fewer');
if (cleanBody.length > 1900) throw new ArgumentError('--body must be 1900 characters or fewer');
return {
createMessageRequest: {
recipients: [cleanRecipient],
subject: cleanSubject,
body: cleanBody,
copyToCrm: Boolean(copyToCrm),
trackingId,
},
};
}
function extractRemainingCredits(json) {
const elements = Array.isArray(json?.elements) ? json.elements : [];
const inmailGrant = elements.find((el) => el?.type === 'LSS_INMAIL' && Number.isInteger(el.value));
if (inmailGrant) return inmailGrant.value;
const candidates = [];
const visit = (value) => {
if (value === null || value === undefined) return;View on GitHub (pinned to 49907e53dc)
Solutions
- Shorten the body to 1900 characters or fewer.
- Split long content into multiple messages or link to an external doc.
- Truncate programmatically: body.slice(0, 1900).
- Strip unnecessary whitespace/quoted text to reduce length.
Example fix
// before --body "$(cat long-pitch.md)" // after --body "$(cat long-pitch.md | head -c 1900)"
Defensive patterns
Strategy: validation
Validate before calling
if (String(body ?? '').trim().length > 1900) throw new Error('shorten --body to 1900 characters or fewer'); Try / catch
try { await sendMessage({ body }); } catch (e) { if (/body must be 1900 characters or fewer/.test(e.message)) { body = body.slice(0, 1900); /* retry */ } else throw e; } Prevention
- Cap outreach templates at ~1900 characters.
- Split long content across messages or link externally.
- Measure the trimmed length, not the raw draft.
- Trim quoted/reply text before sending.
When it happens
Trigger: cleanBody.length > 1900 — the trimmed message body exceeds 1900 characters.
Common situations: Sending long templated outreach, multi-paragraph follow-ups, or pasted documents; concatenating message drafts that overshoot the cap.
Related errors
- --subject must be 200 characters or fewer
- limit must be <= ${MAX_LIMIT}
- archive snapshots limit must be <= 1000
- coingecko limit must be <= 250 (per_page upper bound)
- facebook marketplace-inbox --limit must be a positive intege
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/f8a8b122c78b9aa2.
Report an issue: GitHub.