jackwener/OpenCLI · error · CommandExecutionError
LinkedIn connection element missing a stable public identifi
Error message
LinkedIn connection element missing a stable public identifier
What it means
After extracting miniProfile.publicIdentifier, mapConnection requires a non-empty identifier free of whitespace or URL-unsafe characters (/ ? # spaces). A connection whose publicIdentifier is empty or contains such characters cannot form a stable profile URL, so CommandExecutionError is thrown.
Source
Thrown at clis/linkedin/connections.js:58
}
}
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 {
rank: index + 1,
name,
occupation: optionalText(mini.occupation, 'occupation'),
public_id: publicId,
connected_at: Number.isFinite(element.createdAt) ? element.createdAt : 0,
url: publicId ? `https://www.linkedin.com/in/${encodeURIComponent(publicId)}` : '',
};
}
cli({
site: 'linkedin',
name: 'connections',View on GitHub (pinned to 49907e53dc)
Solutions
- Update the library — newer versions may fall back to the member URN instead of throwing.
- Retry later; transient identifier states often resolve once LinkedIn finishes profile migrations.
- Locally relax the guard: derive the fallback id from element.profileUrn or entityUrn when publicIdentifier fails validation.
- File an issue with the failing connection's sanitized publicIdentifier so the validation regex can be adjusted.
Example fix
// before
if (!publicId || /[\s/?#]/.test(publicId)) {
throw new CommandExecutionError('LinkedIn connection element missing a stable public identifier');
}
// after
if (!publicId || /[\s/?#]/.test(publicId)) {
publicId = String(element.profileUrn || '').replace(/^urn:li:fs_profile:/, '') || 'unknown';
} Defensive patterns
Strategy: validation
Validate before calling
function isStablePublicId(id) {
return typeof id === 'string' && id.length > 0 && !/[\s/?#]/.test(id);
}
if (rows.some(r => !isStablePublicId(r.public_id))) {
console.warn('Response contains unstable public identifiers; avoid building profile URLs from them.');
} Type guard
function isValidPublicId(v) {
return typeof v === 'string' && v.length > 0 && !/[\s/?#]/.test(v);
} Try / catch
try {
const rows = await opencli.linkedin.connections({ limit: 20 });
} catch (e) {
if (/missing a stable public identifier/.test(e.message || '')) {
console.warn('A connection has no usable publicIdentifier; retry or skip that record.');
return [];
}
throw e;
} Prevention
- Never assume every connection has a custom public URL.
- Fall back to profile URNs when publicIdentifier looks unusual.
- Report recurring identifier shapes to maintainers so the regex is updated.
When it happens
Trigger: A connection's miniProfile.publicIdentifier is an empty string, only whitespace, or contains /, ?, or # (e.g. legacy IDs or encoded identifiers) while running `linkedin connections`.
Common situations: Members without a custom public profile URL; recently renamed profiles where publicIdentifier is temporarily unstable; new LinkedIn ID formats breaking the regex assumption.
Related errors
- --note must be 300 characters or fewer for LinkedIn connecti
- LinkedIn connections returned an element without a miniProfi
- LinkedIn sent invitations contained a malformed invitation c
- Zhihu collection returned a malformed item without title or
- INVALID_ARGUMENT
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/544f9a05ed33166e.
Report an issue: GitHub.