{"record":{"id":"5b9ed6fe4f41b812","repo":"TryGhost/Ghost","slug":"the-url-must-be-in-a-format-like-https-www-insta","errorCode":null,"errorMessage":"The URL must be in a format like https://www.instagram.com/yourUsername","messagePattern":"The URL must be in a format like https://www\\.instagram\\.com/yourUsername","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"apps/admin/src/settings/app/utils/social-urls/instagram.ts","lineNumber":23,"sourceCode":"// underscores and periods, up to 30 characters, with no leading, trailing or\n// consecutive periods. Threads reuses this rule — Threads accounts are\n// Instagram accounts.\nexport const INSTAGRAM_USERNAME_RULE: UsernameRule = {\n    extra: '._',\n    min: 1,\n    max: 30,\n    notAtBoundary: '.',\n    notConsecutive: '.'\n};\n\nconst instagram = createPlatformValidator({\n    domains: ['instagram.com'],\n    www: true,\n    pathTypes: [\n        {urlPrefix: '', storagePrefix: '', rule: INSTAGRAM_USERNAME_RULE}\n    ],\n    errors: {\n        invalidUrl: 'The URL must be in a format like https://www.instagram.com/yourUsername',\n        invalidUsername: 'Your Username is not a valid Instagram Username'\n    }\n});\n\nexport const validateInstagramUrl = instagram.validate;\nexport const instagramHandleToUrl = instagram.handleToUrl;\nexport const instagramUrlToHandle = instagram.urlToHandle;\n","sourceCodeStart":5,"sourceCodeEnd":31,"githubUrl":"https://github.com/TryGhost/Ghost/blob/47d8b0e2ad2fd4757d3bc45f46c3ac165ff8a1fe/apps/admin/src/settings/app/utils/social-urls/instagram.ts#L5-L31","documentation":"Thrown by the platform-validator engine for the Instagram definition when input is URL-shaped but can't be resolved to a valid instagram.com profile URL. Message declared in instagram.ts ('The URL must be in a format like https://www.instagram.com/yourUsername'); thrown in platform-validator.ts at: URL regex non-match (line 227 — wrong domain), no path-type match or empty remainder (line 233 — e.g. 'https://www.instagram.com/' with empty username), or built URL failing validator.isURL (line 263). The Instagram path type has an empty urlPrefix, so the username is the first path segment.","triggerScenarios":"Input is URL-shaped but: the domain isn't instagram.com; the path after instagram.com/ is empty; a built canonical URL fails validator.isURL. Bare handles that fail the INSTAGRAM_USERNAME_RULE (charset/length/boundary) route to invalidUsername instead. Wrong-domain URLs (e.g. 'https://facebook.com/user') throw invalidUrl here.","commonSituations":"User pasted a URL for a different platform; user entered 'https://www.instagram.com' with no username; URL contains characters validator.isURL rejects; user pasted a reel/post URL (first segment is still taken as the profile, which may pass or fail the username rule).","solutions":["Use a profile URL like https://www.instagram.com/yourUsername or a bare handle (2–30 chars, allowed charset, no boundary/consecutive dots).","Confirm the domain is instagram.com.","Ensure the path after the domain isn't empty.","For non-throwing checks, use instagramUrlToHandle(url) which returns null on invalid input."],"exampleFix":"// before — throws on wrong-domain or empty-path URL\nconst normalized = validateInstagramUrl(value);\n\n// after — non-throwing pre-check, then validate\nimport {instagramUrlToHandle, validateInstagramUrl} from './instagram';\nconst trimmed = value.trim();\ntry {\n    if (trimmed && trimmed.includes('://') && instagramUrlToHandle(trimmed) === null) {\n        setFieldError('instagram', 'Use an instagram.com profile URL');\n    } else {\n        setNormalized(validateInstagramUrl(trimmed));\n    }\n} catch (e) {\n    setFieldError('instagram', e instanceof Error ? e.message : 'Invalid Instagram URL');\n}","handlingStrategy":"try-catch","validationCode":"// Non-throwing pre-check using the URL→handle extractor\nimport {instagramUrlToHandle} from './instagram';\nfunction looksLikeInstagramUrl(input: string): boolean {\n    if (!input || !input.includes('://')) return true;\n    return instagramUrlToHandle(input) !== null;\n}","typeGuard":"null","tryCatchPattern":"try {\n    const normalized = validateInstagramUrl(value.trim());\n} catch (e) {\n    setFieldError('instagram', e instanceof Error ? e.message : 'Invalid Instagram URL');\n}","preventionTips":["Use an instagram.com profile URL or a bare handle (2–30 chars, allowed charset, no boundary/consecutive dots).","Ensure the path after the domain isn't empty.","Use instagramUrlToHandle for non-throwing URL checks.","Strip whitespace and trailing slashes before validating."],"tags":["instagram","social-urls","validation"],"backgroundTag":null,"analyzedSha":"47d8b0e2ad2fd4757d3bc45f46c3ac165ff8a1fe","analyzedAt":"2026-08-13T01:25:26.651Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}