{"record":{"id":"f8a8b122c78b9aa2","repo":"jackwener/OpenCLI","slug":"body-must-be-1900-characters-or-fewer","errorCode":null,"errorMessage":"--body must be 1900 characters or fewer","messagePattern":"--body must be 1900 characters or fewer","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/linkedin/salesnav-message.js","lineNumber":95,"sourceCode":"  return `https://www.linkedin.com/sales-api/salesApiProfiles/${key}?decoration=${encodeRestliDecoration(PROFILE_DECO)}`;\n}\n\nfunction randomTrackingId() {\n  const bytes = new Uint8Array(8);\n  if (globalThis.crypto?.getRandomValues) globalThis.crypto.getRandomValues(bytes);\n  else for (let i = 0; i < bytes.length; i += 1) bytes[i] = Math.floor(Math.random() * 256);\n  return Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');\n}\n\nfunction buildCreateMessagePayload({ recipientUrn, subject, body, trackingId = randomTrackingId(), copyToCrm = false }) {\n  const cleanRecipient = normalizeWhitespace(recipientUrn);\n  if (!parseSalesProfileUrn(cleanRecipient)) throw new ArgumentError('--recipient must resolve to a Sales Navigator lead urn');\n  const cleanSubject = normalizeWhitespace(subject);\n  const cleanBody = String(body ?? '').trim();\n  if (!cleanSubject) throw new ArgumentError('--subject is required');\n  if (!cleanBody) throw new ArgumentError('--body is required');\n  if (cleanSubject.length > 200) throw new ArgumentError('--subject must be 200 characters or fewer');\n  if (cleanBody.length > 1900) throw new ArgumentError('--body must be 1900 characters or fewer');\n  return {\n    createMessageRequest: {\n      recipients: [cleanRecipient],\n      subject: cleanSubject,\n      body: cleanBody,\n      copyToCrm: Boolean(copyToCrm),\n      trackingId,\n    },\n  };\n}\n\nfunction extractRemainingCredits(json) {\n  const elements = Array.isArray(json?.elements) ? json.elements : [];\n  const inmailGrant = elements.find((el) => el?.type === 'LSS_INMAIL' && Number.isInteger(el.value));\n  if (inmailGrant) return inmailGrant.value;\n  const candidates = [];\n  const visit = (value) => {\n    if (value === null || value === undefined) return;","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/linkedin/salesnav-message.js#L77-L113","documentation":"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.","triggerScenarios":"cleanBody.length > 1900 — the trimmed message body exceeds 1900 characters.","commonSituations":"Sending long templated outreach, multi-paragraph follow-ups, or pasted documents; concatenating message drafts that overshoot the cap.","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."],"exampleFix":"// before\n--body \"$(cat long-pitch.md)\"\n// after\n--body \"$(cat long-pitch.md | head -c 1900)\"","handlingStrategy":"validation","validationCode":"if (String(body ?? '').trim().length > 1900) throw new Error('shorten --body to 1900 characters or fewer');","typeGuard":null,"tryCatchPattern":"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; }","preventionTips":["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."],"tags":["argument-validation","limits","input"],"backgroundTag":"input-length-limit-exceeded","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}