TryGhost/Ghost · warning

The URL must be in a format like https://www.youtube.com/@yo

Error message

The URL must be in a format like https://www.youtube.com/@yourUsername, https://www.youtube.com/user/yourUsername, or https://www.youtube.com/channel/yourChannelId

What it means

Thrown by the platform-validator engine for the YouTube definition when input is URL-shaped but can't be resolved to a valid youtube.com profile URL. Message declared in youtube.ts (the long 'https://www.youtube.com/@yourUsername, /user/yourUsername, or /channel/yourChannelId' form); thrown in platform-validator.ts at: URL regex non-match (line 227 — wrong domain), no path-type prefix match among @/user//channel/ or empty remainder (line 233 — e.g. 'https://www.youtube.com/' with no recognised prefix, or 'https://www.youtube.com/@' with empty handle), or built URL failing validator.isURL (line 263).

Source

Thrown at apps/admin/src/settings/app/utils/social-urls/youtube.ts:16

import {createPlatformValidator} from './platform-validator';

// YouTube profile URLs come in three shapes: modern @handles (3–30 chars,
// letters/numbers/._- with no boundary punctuation — non-Latin scripts are
// supported), legacy /user/ usernames and /channel/ IDs (UC + 22 chars).
// Bare input defaults to an @handle.
const youtube = createPlatformValidator({
    domains: ['youtube.com'],
    www: true,
    pathTypes: [
        {urlPrefix: '@', storagePrefix: '@', rule: {unicode: true, extra: '._-', min: 3, max: 30, notAtBoundary: '._-', notConsecutive: '.'}},
        {urlPrefix: 'user/', storagePrefix: 'user/', rule: {extra: '._-', min: 1, max: 50}},
        {urlPrefix: 'channel/', storagePrefix: 'channel/', rule: {patterns: [/^UC[a-zA-Z0-9_-]{22}$/]}}
    ],
    errors: {
        invalidUrl: 'The URL must be in a format like https://www.youtube.com/@yourUsername, https://www.youtube.com/user/yourUsername, or https://www.youtube.com/channel/yourChannelId',
        invalidUsername: 'Your Username is not a valid YouTube Username'
    }
});

export const validateYouTubeUrl = youtube.validate;
export const youtubeHandleToUrl = youtube.handleToUrl;
export const youtubeUrlToHandle = youtube.urlToHandle;

View on GitHub (pinned to 47d8b0e2ad)

Solutions

  1. Use one of: https://www.youtube.com/@yourHandle, https://www.youtube.com/user/yourUsername, or https://www.youtube.com/channel/UC... (22 chars after UC).
  2. Confirm the domain is youtube.com and the path starts with @, user/, or channel/.
  3. Ensure the segment after the prefix isn't empty.
  4. For non-throwing checks, use youtubeUrlToHandle(url) which returns null on invalid input.

Example fix

// before — throws on watch-URL or empty-path URL
const normalized = validateYouTubeUrl(value);

// after — non-throwing pre-check, then validate
import {youtubeUrlToHandle, validateYouTubeUrl} from './youtube';
const trimmed = value.trim();
try {
    if (trimmed && trimmed.includes('://') && youtubeUrlToHandle(trimmed) === null) {
        setFieldError('youtube', 'Use youtube.com/@handle, /user/name, or /channel/UC...');
    } else {
        setNormalized(validateYouTubeUrl(trimmed));
    }
} catch (e) {
    setFieldError('youtube', e instanceof Error ? e.message : 'Invalid YouTube URL');
}
Defensive patterns

Strategy: try-catch

Validate before calling

// Non-throwing pre-check using the URL→handle extractor
import {youtubeUrlToHandle} from './youtube';
function looksLikeYouTubeUrl(input: string): boolean {
    if (!input || !input.includes('://')) return true;
    return youtubeUrlToHandle(input) !== null;
}

Type guard

null

Try / catch

try {
    const normalized = validateYouTubeUrl(value.trim());
} catch (e) {
    setFieldError('youtube', e instanceof Error ? e.message : 'Invalid YouTube URL');
}

Prevention

When it happens

Trigger: Input is URL-shaped but: the domain isn't youtube.com; the path doesn't start with '@', 'user/', or 'channel/' (e.g. 'https://www.youtube.com/watch?v=...' — a video URL, not a profile); the remainder after the prefix is empty; or the built canonical URL fails validator.isURL. Bare handles that fail the matched path-type's rule route to invalidUsername. Note '@handle' supports Unicode; 'user/' is legacy alphanumeric+._- (1–50); 'channel/' must match /^UC[a-zA-Z0-9_-]{22}$.

Common situations: User pasted a YouTube video/watch URL instead of a channel/profile URL; user entered 'https://www.youtube.com' with no path; user pasted a URL for a different platform; URL with characters validator.isURL rejects.

Related errors


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