{"record":{"id":"544f9a05ed33166e","repo":"jackwener/OpenCLI","slug":"linkedin-connection-element-missing-a-stable-publi","errorCode":null,"errorMessage":"LinkedIn connection element missing a stable public identifier","messagePattern":"LinkedIn connection element missing a stable public identifier","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/linkedin/connections.js","lineNumber":58,"sourceCode":"    }\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}\n\ncli({\n    site: 'linkedin',\n    name: 'connections',","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/linkedin/connections.js#L40-L76","documentation":"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.","triggerScenarios":"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`.","commonSituations":"Members without a custom public profile URL; recently renamed profiles where publicIdentifier is temporarily unstable; new LinkedIn ID formats breaking the regex assumption.","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."],"exampleFix":"// before\nif (!publicId || /[\\s/?#]/.test(publicId)) {\n    throw new CommandExecutionError('LinkedIn connection element missing a stable public identifier');\n}\n// after\nif (!publicId || /[\\s/?#]/.test(publicId)) {\n    publicId = String(element.profileUrn || '').replace(/^urn:li:fs_profile:/, '') || 'unknown';\n}","handlingStrategy":"validation","validationCode":"function isStablePublicId(id) {\n  return typeof id === 'string' && id.length > 0 && !/[\\s/?#]/.test(id);\n}\nif (rows.some(r => !isStablePublicId(r.public_id))) {\n  console.warn('Response contains unstable public identifiers; avoid building profile URLs from them.');\n}","typeGuard":"function isValidPublicId(v) {\n  return typeof v === 'string' && v.length > 0 && !/[\\s/?#]/.test(v);\n}","tryCatchPattern":"try {\n  const rows = await opencli.linkedin.connections({ limit: 20 });\n} catch (e) {\n  if (/missing a stable public identifier/.test(e.message || '')) {\n    console.warn('A connection has no usable publicIdentifier; retry or skip that record.');\n    return [];\n  }\n  throw e;\n}","preventionTips":["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."],"tags":["linkedin","data-quality","validation"],"backgroundTag":"missing-response-field","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}