{"record":{"id":"64925cb656ce12cb","repo":"BoundaryML/baml","slug":"video-is-not-base64-64925c","errorCode":null,"errorMessage":"Video is not base64","messagePattern":"Video is not base64","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"engine/language_client_typescript/video.js","lineNumber":79,"sourceCode":"    }\n    /**\n     * Get the URL of the video if it's stored as a URL\n     * @throws Error if the video is not stored as a URL\n     */\n    asUrl() {\n        if (!this.isUrl()) {\n            throw new Error(\"Video is not a URL\");\n        }\n        return this.content;\n    }\n    /**\n     * Get the base64 data and media type if the video is stored as base64\n     * @returns [base64Data, mediaType]\n     * @throws Error if the video is not stored as base64\n     */\n    asBase64() {\n        if (this.type !== \"base64\") {\n            throw new Error(\"Video is not base64\");\n        }\n        return [this.content, this.mediaType || \"\"];\n    }\n    /**\n     * Convert the video to a JSON representation\n     */\n    toJSON() {\n        if (this.type === \"url\") {\n            return { url: this.content };\n        }\n        return {\n            base64: this.content,\n            media_type: this.mediaType || \"\",\n        };\n    }\n}\nexports.BamlVideo = BamlVideo;\n","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_typescript/video.js#L61-L97","documentation":"JavaScript (compiled) version of Video.asBase64(): throws when this.type !== \"base64\", i.e. the video is URL-backed. Returns [base64Data, mediaType] only for base64-stored videos. Same semantics as the TypeScript source in typescript_src/video.ts.","triggerScenarios":"Calling video.asBase64() on a URL-backed Video instance in a project consuming the compiled engine/language_client_typescript/video.js build.","commonSituations":"Building payloads for model APIs that accept inline base64 media while the app stores videos as URLs; code shared between URL-only and base64-only flows without a representation check.","solutions":["Check video.type === \"base64\" (or !video.isUrl()) before calling asBase64()","Download the URL content and encode to base64 yourself before calling base64-only APIs","Store the video as base64 at construction time when the downstream consumer requires it","Write a normalizeVideo helper that handles both representations once"],"exampleFix":"// before\nconst [data, mediaType] = video.asBase64();\n// after\nconst [data, mediaType] = video.isUrl()\n  ? await videoToBase64(video.asUrl())\n  : video.asBase64();","handlingStrategy":"type-guard","validationCode":"if (!video || video.type !== \"base64\") {\n  // convert from URL first\n}","typeGuard":"function isBase64Video(video) { return !!video && video.type === \"base64\"; }","tryCatchPattern":"let result;\ntry {\n  result = video.asBase64();\n} catch (e) {\n  if (!/not base64/.test(e.message)) throw e;\n  result = null; // handle URL-backed video\n}","preventionTips":["Branch on video.type before calling asBase64()","Normalize videos to base64 at load time if your pipeline needs inline media","Keep a single helper for URL-to-base64 conversion with media-type handling"],"tags":["javascript","video","multimodal","base64","content-type"],"backgroundTag":"incompatible-source-type","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}