{"record":{"id":"aeedf08046c73cda","repo":"jackwener/OpenCLI","slug":"body-is-required","errorCode":null,"errorMessage":"--body is required","messagePattern":"--body is required","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/linkedin/salesnav-message.js","lineNumber":93,"sourceCode":"  if (!recipient?.profileId || !recipient?.authType || !recipient?.authToken) return '';\n  const key = `(profileId:${recipient.profileId},authType:${recipient.authType},authToken:${recipient.authToken})`;\n  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 = [];","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/linkedin/salesnav-message.js#L75-L111","documentation":"buildCreateMessagePayload requires a non-empty body (trimmed); an empty message body is rejected before the API call with an ArgumentError.","triggerScenarios":"--body is omitted, empty, or contains only whitespace.","commonSituations":"Omitting --body on the CLI; heredoc/quoting mistakes yielding an empty string; programmatic payload building passing undefined body.","solutions":["Provide --body \"Your message text\".","Verify shell quoting so multiline bodies are passed intact.","Ensure the body has at least one non-whitespace character."],"exampleFix":"// before\nlinkedin salesnav-message --recipient \"...\" --subject \"Hi\"\n// after\nlinkedin salesnav-message --recipient \"...\" --subject \"Hi\" --body \"Let's connect.\"","handlingStrategy":"validation","validationCode":"if (!args.body || !String(args.body).trim()) throw new Error('pass a non-empty --body');","typeGuard":"function hasBody(a) { return typeof a.body === 'string' && a.body.trim().length > 0; }","tryCatchPattern":"try { await sendMessage(args); } catch (e) { if (/--body is required/.test(e.message)) { console.error('Body text missing; supply --body'); process.exitCode = 2; } else throw e; }","preventionTips":["Always pass --body with quoted text.","Check heredoc/pipe sources actually produced content.","Trim templates so whitespace-only drafts are rejected early.","Validate body in a pre-flight check."],"tags":["argument-validation","cli","input"],"backgroundTag":"missing-required-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}