TryGhost/Ghost · warning

Your Username is not a valid LinkedIn Username

Error message

Your Username is not a valid LinkedIn Username

What it means

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).

Source

Thrown at apps/admin/src/settings/app/utils/social-urls/linkedin.ts:29

    max: 100
};

// /in/ profiles are stored as a bare handle; the other path types keep their
// prefix in storage. Regional subdomains (uk.linkedin.com) are valid input and
// stay in the validated URL, but are dropped from the stored handle.
const linkedin = createPlatformValidator({
    domains: ['linkedin.com'],
    www: true,
    regionalSubdomain: '[a-z]{2}',
    pathTypes: [
        {urlPrefix: 'in/', storagePrefix: '', handleAliases: ['in/'], rule: LINKEDIN_USERNAME_RULE},
        {urlPrefix: 'pub/', storagePrefix: 'pub/', rule: {...LINKEDIN_USERNAME_RULE, nestedSegments: true}},
        {urlPrefix: 'company/', storagePrefix: 'company/', rule: LINKEDIN_USERNAME_RULE},
        {urlPrefix: 'school/', storagePrefix: 'school/', rule: LINKEDIN_USERNAME_RULE}
    ],
    errors: {
        invalidUrl: 'The URL must be in a format like https://www.linkedin.com/in/yourUsername',
        invalidUsername: 'Your Username is not a valid LinkedIn Username'
    }
});

export const validateLinkedInUrl = linkedin.validate;
export const linkedinHandleToUrl = linkedin.handleToUrl;
export const linkedinUrlToHandle = linkedin.urlToHandle;

View on GitHub (pinned to 47d8b0e2ad)

Solutions

  1. Use a LinkedIn username matching LINKEDIN_USERNAME_RULE (alphanumerics and allowed characters); for /pub/, keep the pub/name/number/number/number structure.
  2. Guard handleToUrl against empty strings before calling.
  3. Strip query strings and fragments from URLs before validation.
  4. When rendering stored handles, wrap handleToUrl in try-catch and omit the link on failure.

Example fix

// before — throws on empty/corrupt stored handle
const url = linkedinHandleToUrl(profile.linkedin);

// after — guard empty, try-catch the rest
const handle = profile.linkedin?.trim();
if (!handle) {
    return null;
}
try {
    return linkedinHandleToUrl(handle);
} catch {
    return null;
}
Defensive patterns

Strategy: try-catch

Validate before calling

// Guard empty handles before calling the converter
function safeLinkedinHandle(handle: string | undefined | null): boolean {
    const h = handle?.trim();
    if (!h) return false;
    // accept the known storage prefixes; full charset check is delegated to the validator
    return /^(in\/|pub\/|company\/|school\/)?[^\s]+$/.test(h);
}

Type guard

null

Try / catch

const handle = profile.linkedin?.trim();
if (!handle) return null;
try {
    return linkedinHandleToUrl(handle);
} catch {
    return null;
}

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


AI-assisted analysis of TryGhost/Ghost@47d8b0e2ad (2026-08-13). Data as JSON: /api/errors/537bccc7117200d0. Report an issue: GitHub.