{"record":{"id":"bd6c8b0d0aac7b4c","repo":"remotion-dev/remotion","slug":"config-addelementlibrary-expects-an-object-got","errorCode":null,"errorMessage":"Config.addElementLibrary() expects an object, got ${receivedType}","messagePattern":"Config\\.addElementLibrary\\(\\) expects an object, got (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cli/src/config/element-libraries.ts","lineNumber":17,"sourceCode":"import type {StudioElementLibrary} from '@remotion/studio-shared';\n\nexport type AddElementLibraryOptions = {\n\treadonly url: string;\n\treadonly displayName?: string;\n};\n\nlet elementLibraries: StudioElementLibrary[] = [];\n\nexport const addElementLibrary = (options: AddElementLibraryOptions) => {\n\tif (\n\t\ttypeof options !== 'object' ||\n\t\toptions === null ||\n\t\tArray.isArray(options)\n\t) {\n\t\tconst receivedType = Array.isArray(options) ? 'an array' : typeof options;\n\t\tthrow new Error(\n\t\t\t`Config.addElementLibrary() expects an object, got ${receivedType}`,\n\t\t);\n\t}\n\n\tconst {url, displayName} = options;\n\tif (typeof url !== 'string') {\n\t\tthrow new Error(\n\t\t\t`Config.addElementLibrary() expects \"url\" to be a string, got ${typeof url}`,\n\t\t);\n\t}\n\n\tlet parsedUrl: URL;\n\ttry {\n\t\tparsedUrl = new URL(url);\n\t} catch {\n\t\tthrow new Error(\n\t\t\t`Config.addElementLibrary() expects an absolute URL, got ${JSON.stringify(url)}`,\n\t\t);","sourceCodeStart":1,"sourceCodeEnd":35,"githubUrl":"https://github.com/remotion-dev/remotion/blob/8f9775815716e25b2a9fd9c5511015a17624243d/packages/cli/src/config/element-libraries.ts#L1-L35","documentation":"Config.addElementLibrary() validates its single options argument and requires a plain object. Passing an array, null, a string, or a primitive throws with the received type in the message.","triggerScenarios":"Calling Config.addElementLibrary(...) with no argument, an array, a string, or a non-object value in remotion.config.ts.","commonSituations":"Copy-pasting a docs example incorrectly, passing a list of libraries, or calling the setter before arguments are constructed.","solutions":["Pass a single options object: Config.addElementLibrary({url: 'https://...', displayName: '...'})","If adding multiple libraries, call addElementLibrary once per library"],"exampleFix":"// before\nConfig.addElementLibrary(['https://example.com/library.json']);\n\n// after\nConfig.addElementLibrary({url: 'https://example.com/library.json', displayName: 'My Library'});","handlingStrategy":"validation","validationCode":"if (typeof opts !== 'object' || opts === null || Array.isArray(opts)) { throw new TypeError('options object required'); }","typeGuard":"const isElementLibraryOptions = (v: unknown): v is {url: string; displayName?: string} => typeof v === 'object' && v !== null && !Array.isArray(v) && typeof (v as any).url === 'string';","tryCatchPattern":null,"preventionTips":["Type your remotion.config.ts against the documented signature","Call once per library, always with an object literal"],"tags":["config","element-library","validation","remotion-config"],"backgroundTag":"config-argument-type-invalid","analyzedSha":"8f9775815716e25b2a9fd9c5511015a17624243d","analyzedAt":"2026-08-28T15:39:09.316Z","contentChangedAt":"2026-08-28T15:39:09.316Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}