{"record":{"id":"e90f2729b898ceb6","repo":"remotion-dev/remotion","slug":"expected-a-url-string-but-received-url-undef","errorCode":null,"errorMessage":"Expected a URL string but received ${url === undefined ? 'undefined' : typeof url}. Make sure to pass a \"url\" field in the options object of loadFont().","messagePattern":"Expected a URL string but received (.+?)\\. Make sure to pass a \"url\" field in the options object of loadFont\\(\\)\\.","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/fonts/src/get-font-format.ts","lineNumber":5,"sourceCode":"export type FontFormat = 'woff2' | 'woff' | 'opentype' | 'truetype';\n\nexport const getFontFormat = (url: string): FontFormat => {\n\tif (typeof url !== 'string') {\n\t\tthrow new TypeError(\n\t\t\t`Expected a URL string but received ${url === undefined ? 'undefined' : typeof url}. Make sure to pass a \"url\" field in the options object of loadFont().`,\n\t\t);\n\t}\n\n\tconst ext = url.split('.').pop()?.toLowerCase();\n\tswitch (ext) {\n\t\tcase 'woff2':\n\t\t\treturn 'woff2';\n\t\tcase 'woff':\n\t\t\treturn 'woff';\n\t\tcase 'otf':\n\t\t\treturn 'opentype';\n\t\tcase 'ttf':\n\t\t\treturn 'truetype';\n\t\tdefault:\n\t\t\tthrow new Error(\n\t\t\t\t`Could not automatically derive font format from extension: ${ext}. Pass the \"format\" parameter explicitly.`,\n\t\t\t);","sourceCodeStart":1,"sourceCodeEnd":23,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/fonts/src/get-font-format.ts#L1-L23","documentation":"The `getFontFormat` helper derives a CSS font format from a URL's file extension. It expects a string argument and throws a TypeError if the value is not a string (e.g., undefined, number, or object). This is called internally by `loadFont` when no explicit `format` is provided, so the error surfaces the missing or mistyped `url` field.","triggerScenarios":"Calling `getFontFormat()` directly with a non-string, or calling `loadFont()` with an options object where `url` is missing or not a string and no `format` is specified. The ternary in the message distinguishes `undefined` from other types for clearer debugging.","commonSituations":"Passing a font configuration object where the `url` key was misspelled or omitted, deserializing font config from JSON where the URL became null, or calling `loadFont({family: 'MyFont'})` without a URL.","solutions":["Ensure the `url` field in `loadFont` options is a non-empty string.","If calling `getFontFormat` directly, pass a valid URL string.","Check for typos in the options key name (e.g., `src` instead of `url`)."],"exampleFix":"// before\nloadFont({ family: 'MyFont' }); // missing url\n\n// after\nloadFont({ family: 'MyFont', url: '/fonts/myfont.woff2' });","handlingStrategy":"type-guard","validationCode":"if (typeof url !== 'string' || url.length === 0) {\n  throw new TypeError('A non-empty url string is required');\n}\nconst format = getFontFormat(url);","typeGuard":"const isNonEmptyString = (v: unknown): v is string =>\n  typeof v === 'string' && v.length > 0;","tryCatchPattern":null,"preventionTips":["Always include a string url field in loadFont options.","Use TypeScript to enforce the LoadFontOptions shape at compile time.","Check for undefined url before calling loadFont when building options dynamically."],"tags":["fonts","validation","typescript","load-font"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}