{"record":{"id":"537bccc7117200d0","repo":"TryGhost/Ghost","slug":"your-username-is-not-a-valid-linkedin-username","errorCode":null,"errorMessage":"Your Username is not a valid LinkedIn Username","messagePattern":"Your Username is not a valid LinkedIn Username","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"apps/admin/src/settings/app/utils/social-urls/linkedin.ts","lineNumber":29,"sourceCode":"    max: 100\n};\n\n// /in/ profiles are stored as a bare handle; the other path types keep their\n// prefix in storage. Regional subdomains (uk.linkedin.com) are valid input and\n// stay in the validated URL, but are dropped from the stored handle.\nconst linkedin = createPlatformValidator({\n    domains: ['linkedin.com'],\n    www: true,\n    regionalSubdomain: '[a-z]{2}',\n    pathTypes: [\n        {urlPrefix: 'in/', storagePrefix: '', handleAliases: ['in/'], rule: LINKEDIN_USERNAME_RULE},\n        {urlPrefix: 'pub/', storagePrefix: 'pub/', rule: {...LINKEDIN_USERNAME_RULE, nestedSegments: true}},\n        {urlPrefix: 'company/', storagePrefix: 'company/', rule: LINKEDIN_USERNAME_RULE},\n        {urlPrefix: 'school/', storagePrefix: 'school/', rule: LINKEDIN_USERNAME_RULE}\n    ],\n    errors: {\n        invalidUrl: 'The URL must be in a format like https://www.linkedin.com/in/yourUsername',\n        invalidUsername: 'Your Username is not a valid LinkedIn Username'\n    }\n});\n\nexport const validateLinkedInUrl = linkedin.validate;\nexport const linkedinHandleToUrl = linkedin.handleToUrl;\nexport const linkedinUrlToHandle = linkedin.urlToHandle;\n","sourceCodeStart":11,"sourceCodeEnd":36,"githubUrl":"https://github.com/TryGhost/Ghost/blob/47d8b0e2ad2fd4757d3bc45f46c3ac165ff8a1fe/apps/admin/src/settings/app/utils/social-urls/linkedin.ts#L11-L36","documentation":"Thrown by the platform-validator engine for the LinkedIn definition when the username portion is invalid, or handleToUrl is called empty. Message declared in linkedin.ts ('Your Username is not a valid LinkedIn Username'); thrown in platform-validator.ts at: query/fragment in a non-fullPath username (line 247), username rule check failure (line 255 — LINKEDIN_USERNAME_RULE charset/length, with nestedSegments for /pub/), or empty handle in handleToUrl (line 280).","triggerScenarios":"The username segment after in//company//school/ fails the LinkedIn rule (charset/length); a /pub/ path has malformed nested sub-segments (e.g. non-numeric after the name); a URL username segment contains '?' or '#' (query/fragment); OR handleToUrl('') with an empty stored handle. The pub/ path type allows nested slash-separated segments (pub/name/12/34/567).","commonSituations":"User typed special characters not in the LinkedIn charset; /pub/ URL with corrupted numeric segments; rendering an empty stored handle; user appended a tracking query string to the profile URL.","solutions":["Use a LinkedIn username matching LINKEDIN_USERNAME_RULE (alphanumerics and allowed characters); for /pub/, keep the pub/name/number/number/number structure.","Guard handleToUrl against empty strings before calling.","Strip query strings and fragments from URLs before validation.","When rendering stored handles, wrap handleToUrl in try-catch and omit the link on failure."],"exampleFix":"// before — throws on empty/corrupt stored handle\nconst url = linkedinHandleToUrl(profile.linkedin);\n\n// after — guard empty, try-catch the rest\nconst handle = profile.linkedin?.trim();\nif (!handle) {\n    return null;\n}\ntry {\n    return linkedinHandleToUrl(handle);\n} catch {\n    return null;\n}","handlingStrategy":"try-catch","validationCode":"// Guard empty handles before calling the converter\nfunction safeLinkedinHandle(handle: string | undefined | null): boolean {\n    const h = handle?.trim();\n    if (!h) return false;\n    // accept the known storage prefixes; full charset check is delegated to the validator\n    return /^(in\\/|pub\\/|company\\/|school\\/)?[^\\s]+$/.test(h);\n}","typeGuard":"null","tryCatchPattern":"const handle = profile.linkedin?.trim();\nif (!handle) return null;\ntry {\n    return linkedinHandleToUrl(handle);\n} catch {\n    return null;\n}","preventionTips":["Match LINKEDIN_USERNAME_RULE for the chosen path type; keep /pub/ nested segments well-formed.","Guard handleToUrl against empty strings.","Strip query strings and fragments from URLs before validation.","Wrap handleToUrl in try-catch when rendering from stored data."],"tags":["linkedin","social-urls","validation"],"backgroundTag":null,"analyzedSha":"47d8b0e2ad2fd4757d3bc45f46c3ac165ff8a1fe","analyzedAt":"2026-08-13T01:25:26.651Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}