TryGhost/Ghost · warning
Your Username is not a valid TikTok Username
Error message
Your Username is not a valid TikTok Username
What it means
Thrown by the platform-validator engine for the TikTok definition when the username is invalid, or handleToUrl is called empty. Message declared in tiktok.ts ('Your Username is not a valid TikTok Username'); thrown in platform-validator.ts at: query/fragment in username (line 247), username rule check failure (line 255 — TikTok rule: 2–24 chars, ASCII letters/digits plus ._ , no boundary or consecutive dots), or empty handle in handleToUrl (line 280).
Source
Thrown at apps/admin/src/settings/app/utils/social-urls/tiktok.ts:13
import {createPlatformValidator} from './platform-validator';
// TikTok usernames are ASCII-only by platform rule: letters, numbers,
// underscores and periods, 2–24 characters, no boundary or consecutive periods.
const tiktok = createPlatformValidator({
domains: ['tiktok.com'],
www: true,
pathTypes: [
{urlPrefix: '@', storagePrefix: '@', rule: {extra: '._', min: 2, max: 24, notAtBoundary: '.', notConsecutive: '.'}}
],
errors: {
invalidUrl: 'The URL must be in a format like https://www.tiktok.com/@yourUsername',
invalidUsername: 'Your Username is not a valid TikTok Username'
}
});
export const validateTikTokUrl = tiktok.validate;
export const tiktokHandleToUrl = tiktok.handleToUrl;
export const tiktokUrlToHandle = tiktok.urlToHandle;
View on GitHub (pinned to 47d8b0e2ad)
Solutions
- Use a TikTok handle of 2–24 characters in [a-zA-Z0-9._] 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 = tiktokHandleToUrl(profile.tiktok);
// after — guard empty, try-catch the rest
const handle = profile.tiktok?.trim();
if (!handle) {
return null;
}
try {
return tiktokHandleToUrl(handle);
} catch {
return null;
} Defensive patterns
Strategy: try-catch
Validate before calling
// Validate the handle shape before calling handleToUrl
function isValidTikTokHandleShape(h: string): boolean {
if (!h || [...h].length < 2 || [...h].length > 24) return false;
if (h.startsWith('.') || h.endsWith('.')) return false;
if (h.includes('..')) return false;
return /^[a-zA-Z0-9._]+$/.test(h);
} Type guard
null
Try / catch
const handle = profile.tiktok?.trim();
if (!handle) return null;
try {
return tiktokHandleToUrl(handle);
} catch {
return null;
} Prevention
- Use 2–24 characters in [a-zA-Z0-9._] with no boundary or 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 the TikTok rule: length outside 2–24; contains characters outside [a-zA-Z0-9._]; 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 >24-character handle; handle with leading/trailing dot; handle with consecutive dots; 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.tiktok.com/@you
- 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/b30e3e89d768229b.
Report an issue: GitHub.