{"record":{"id":"53a250a437440970","repo":"jackwener/OpenCLI","slug":"linkedin-connections-returned-an-element-without-a","errorCode":null,"errorMessage":"LinkedIn connections returned an element without a miniProfile","messagePattern":"LinkedIn connections returned an element without a miniProfile","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/linkedin/connections.js","lineNumber":54,"sourceCode":"            return { error: 'response was not valid JSON' };\n        }\n    } catch (e) {\n        return { error: 'fetch failed: ' + ((e && e.message) || String(e)) };\n    }\n}\n\nfunction optionalText(value, field) {\n    if (value == null) return '';\n    if (typeof value !== 'string') {\n        throw new CommandExecutionError(`LinkedIn connection miniProfile field ${field} was malformed`);\n    }\n    return normalizeWhitespace(value);\n}\n\nfunction mapConnection(element, index) {\n    const mini = element && element.miniProfile;\n    if (!mini || typeof mini !== 'object') {\n        throw new CommandExecutionError('LinkedIn connections returned an element without a miniProfile');\n    }\n    const publicId = optionalText(mini.publicIdentifier, 'publicIdentifier');\n    if (!publicId || /[\\s/?#]/.test(publicId)) {\n        throw new CommandExecutionError('LinkedIn connection element missing a stable public identifier');\n    }\n    const name = normalizeWhitespace([\n        optionalText(mini.firstName, 'firstName'),\n        optionalText(mini.lastName, 'lastName'),\n    ].filter(Boolean).join(' ')) || publicId;\n    return {\n        rank: index + 1,\n        name,\n        occupation: optionalText(mini.occupation, 'occupation'),\n        public_id: publicId,\n        connected_at: Number.isFinite(element.createdAt) ? element.createdAt : 0,\n        url: publicId ? `https://www.linkedin.com/in/${encodeURIComponent(publicId)}` : '',\n    };\n}","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/linkedin/connections.js#L36-L72","documentation":"mapConnection() requires every element of the connections API response to carry a miniProfile object. If an element lacks miniProfile or it is not an object (LinkedIn sometimes returns shadow entities for removed/hidden members), CommandExecutionError is thrown because rank/name/public_id cannot be derived.","triggerScenarios":"Running `linkedin connections` when a page of the Voyager response contains an element whose miniProfile is null/undefined — typically for deactivated, restricted, or hidden-from-list connections.","commonSituations":"A connection deleted or restricted their account; LinkedIn filtering a member from public view while still listing the relationship; API contract drift adding new element types.","solutions":["Update the CLI to a version that skips elements without miniProfile instead of throwing.","Retry with a smaller limit to isolate which page contains the bad element.","Locally patch mapConnection to `if (!mini || typeof mini !== 'object') return null;` and filter nulls from rows.","Report the occurrence to the library maintainers with the approximate total connection count."],"exampleFix":"// before\nif (!mini || typeof mini !== 'object') {\n    throw new CommandExecutionError('LinkedIn connections returned an element without a miniProfile');\n}\n// after\nif (!mini || typeof mini !== 'object') return null; // filtered later: elements.map(mapConnection).filter(Boolean)","handlingStrategy":"type-guard","validationCode":"// Guard at consumption time\nconst connections = (await opencli.linkedin.connections({ limit: 20 }))\n  .filter(r => r && r.public_id);","typeGuard":"function hasMiniProfile(element) {\n  return Boolean(element && typeof element === 'object' && element.miniProfile && typeof element.miniProfile === 'object');\n}","tryCatchPattern":"try {\n  const rows = await opencli.linkedin.connections({ limit: 20 });\n} catch (e) {\n  if (/without a miniProfile/.test(e.message || '')) {\n    console.warn('A connection element lacked miniProfile (restricted/deleted member); retrying with smaller limit.');\n    return opencli.linkedin.connections({ limit: 10 });\n  }\n  throw e;\n}","preventionTips":["Prefer smaller pagination limits so one bad element costs less.","Keep the CLI updated for tolerant element-skipping behavior.","Expect occasional null miniProfile for deactivated accounts; handle empty rows defensively."],"tags":["linkedin","schema-validation","data-quality"],"backgroundTag":"missing-response-field","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}