TryGhost/Ghost · warning
Your Username is not a valid Instagram Username
Error message
Your Username is not a valid Instagram Username
What it means
Thrown by the platform-validator engine for the Instagram definition when the username is invalid, or handleToUrl is called empty. Message declared in instagram.ts ('Your Username is not a valid Instagram Username'); thrown in platform-validator.ts at: query/fragment in username (line 247), username rule check failure (line 255 — INSTAGRAM_USERNAME_RULE: 2–30 chars, allowed charset, no boundary/consecutive dots), or empty handle in handleToUrl (line 280).
Source
Thrown at apps/admin/src/settings/app/utils/social-urls/instagram.ts:24
// consecutive periods. Threads reuses this rule — Threads accounts are
// Instagram accounts.
export const INSTAGRAM_USERNAME_RULE: UsernameRule = {
extra: '._',
min: 1,
max: 30,
notAtBoundary: '.',
notConsecutive: '.'
};
const instagram = createPlatformValidator({
domains: ['instagram.com'],
www: true,
pathTypes: [
{urlPrefix: '', storagePrefix: '', rule: INSTAGRAM_USERNAME_RULE}
],
errors: {
invalidUrl: 'The URL must be in a format like https://www.instagram.com/yourUsername',
invalidUsername: 'Your Username is not a valid Instagram Username'
}
});
export const validateInstagramUrl = instagram.validate;
export const instagramHandleToUrl = instagram.handleToUrl;
export const instagramUrlToHandle = instagram.urlToHandle;
View on GitHub (pinned to 47d8b0e2ad)
Solutions
- Use an Instagram handle of 2–30 characters in the allowed charset, with no leading/trailing dot and no consecutive dots.
- 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.
Example fix
// before — throws on empty/corrupt stored handle or out-of-rule handle
const url = instagramHandleToUrl(profile.instagram);
// after — guard empty, try-catch the rest
const handle = profile.instagram?.trim();
if (!handle) {
return null;
}
try {
return instagramHandleToUrl(handle);
} catch {
return null;
} Defensive patterns
Strategy: try-catch
Validate before calling
// Validate the handle shape before calling handleToUrl
function isValidInstagramHandleShape(h: string): boolean {
if (!h || [...h].length < 2 || [...h].length > 30) return false;
if (h.startsWith('.') || h.endsWith('.')) return false;
if (h.includes('..')) return false;
return true; // full charset check delegated to the validator
} Type guard
null
Try / catch
const handle = profile.instagram?.trim();
if (!handle) return null;
try {
return instagramHandleToUrl(handle);
} catch {
return null;
} Prevention
- Use 2–30 characters with no leading/trailing dot and no consecutive dots.
- Guard handleToUrl against empty strings.
- Strip query strings and fragments from URLs before validation.
- Wrap handleToUrl in try-catch when rendering from stored data.
When it happens
Trigger: Username fails INSTAGRAM_USERNAME_RULE: length outside 2–30; contains disallowed characters; starts or ends with a dot (notAtBoundary: '.'); contains consecutive dots '..' (notConsecutive: '.'); OR handleToUrl('') with an empty stored handle; OR a URL username segment contains '?' or '#' (query/fragment).
Common situations: User typed a 1-character or >30-character handle; handle with leading/trailing dot ('.user'); handle with consecutive dots ('us..er'); rendering an empty stored handle; user appended a query string to the URL.
Related errors
- The URL must be in a format like https://www.instagram.com/y
- The URL must be in a format like @username@instance.tld or h
- Your Username is not a valid Mastodon Username
- The URL must be in a format like https://x.com/yourUsername
- Your Username is not a valid Twitter Username
AI-assisted analysis of TryGhost/Ghost@47d8b0e2ad (2026-08-13).
Data as JSON: /api/errors/1c9f4a390e986bc5.
Report an issue: GitHub.