jackwener/OpenCLI · error · CommandExecutionError
LinkedIn connection miniProfile field ${field} was malformed
Error message
LinkedIn connection miniProfile field ${field} was malformed What it means
optionalText() in connections.js validates fields of each connection's miniProfile object from LinkedIn's /voyager/api/relationships/connections response. If a field like publicIdentifier, firstName, lastName or occupation is present but not a string (e.g. a number, object, or array due to a Voyager schema change), it throws CommandExecutionError naming the offending field.
Source
Thrown at clis/linkedin/connections.js:46
if (!res.ok) return { error: 'HTTP ' + res.status };
const contentType = res.headers?.get?.('content-type') || '';
if (/\btext\/html\b/i.test(contentType)) {
return { authRequired: true, error: 'HTML auth/checkpoint response' };
}
try {
return { json: await res.json() };
} catch {
return { error: 'response was not valid JSON' };
}
} catch (e) {
return { error: 'fetch failed: ' + ((e && e.message) || String(e)) };
}
}
function optionalText(value, field) {
if (value == null) return '';
if (typeof value !== 'string') {
throw new CommandExecutionError(`LinkedIn connection miniProfile field ${field} was malformed`);
}
return normalizeWhitespace(value);
}
function mapConnection(element, index) {
const mini = element && element.miniProfile;
if (!mini || typeof mini !== 'object') {
throw new CommandExecutionError('LinkedIn connections returned an element without a miniProfile');
}
const publicId = optionalText(mini.publicIdentifier, 'publicIdentifier');
if (!publicId || /[\s/?#]/.test(publicId)) {
throw new CommandExecutionError('LinkedIn connection element missing a stable public identifier');
}
const name = normalizeWhitespace([
optionalText(mini.firstName, 'firstName'),
optionalText(mini.lastName, 'lastName'),
].filter(Boolean).join(' ')) || publicId;
return {View on GitHub (pinned to 49907e53dc)
Solutions
- Update the library to the latest version in case a schema-change fix was released.
- Capture the raw API payload and file an issue including the malformed field name from the message.
- As a workaround, downgrade the limit or retry later — LinkedIn A/B variants sometimes revert.
- Patch optionalText locally to coerce known object shapes (e.g. {text}) via normalizeWhitespace(String(value.text)).
Example fix
// before
if (typeof value !== 'string') {
throw new CommandExecutionError(`LinkedIn connection miniProfile field ${field} was malformed`);
}
// after
if (typeof value !== 'string') {
if (value && typeof value === 'object' && typeof value.text === 'string') return normalizeWhitespace(value.text);
throw new CommandExecutionError(`LinkedIn connection miniProfile field ${field} was malformed`);
} Defensive patterns
Strategy: type-guard
Validate before calling
if (mini.publicIdentifier != null && typeof mini.publicIdentifier !== 'string') {
throw new Error('miniProfile.publicIdentifier is not a string — LinkedIn schema may have changed.');
} Type guard
function isTextField(v) {
return v == null || typeof v === 'string';
}
const miniOk = isTextField(mini.publicIdentifier) && isTextField(mini.firstName) && isTextField(mini.lastName); Try / catch
try {
const rows = await opencli.linkedin.connections({ limit: 20 });
} catch (e) {
if (e.name === 'CommandExecutionError' && /miniProfile field .* was malformed/.test(e.message)) {
console.warn('LinkedIn schema drift on field:', e.message.match(/field (\w+)/)?.[1]);
return [];
}
throw e;
} Prevention
- Pin and regularly update the CLI; Voyager schema drift is fixed upstream.
- Validate captured API payloads against expected miniProfile fields in tests.
- Watch for reports of field-shape changes after LinkedIn releases.
When it happens
Trigger: Mapping a connection element (via mapConnection -> publicId/name/occupation) where miniProfile.<field> is non-null and non-string, e.g. LinkedIn returns publicIdentifier as a structured object or firstName as a localized text object.
Common situations: LinkedIn silently changing the Voyager miniProfile schema; A/B test cohorts receiving new field shapes; accounts where a contact has no public profile so publicIdentifier takes an unexpected type.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- LinkedIn connections API returned a malformed payload: missi
- returned malformed items payload
- LinkedIn connections returned an element without a miniProfi
- LinkedIn messaging API returned malformed normalized payload
- LinkedIn messaging API returned a conversation without threa
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/0bbaeb9a9cc9d77b.
Report an issue: GitHub.