{"record":{"id":"25c6af3f20ab16b9","repo":"BoundaryML/baml","slug":"video-is-not-a-url-25c6af","errorCode":null,"errorMessage":"Video is not a URL","messagePattern":"Video is not a URL","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"engine/language_client_typescript/video.js","lineNumber":68,"sourceCode":"     */\n    static async fromUrlAsync(url) {\n        const response = await fetch(url);\n        const blob = await response.blob();\n        return BamlVideo.fromBlob(blob);\n    }\n    /**\n     * Check if the video is stored as a URL\n     */\n    isUrl() {\n        return this.type === \"url\";\n    }\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() {","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/language_client_typescript/video.js#L50-L86","documentation":"JavaScript (compiled) version of Video.asUrl(): throws when the video is not stored as a URL, i.e. this.isUrl() is false. It exists so callers can extract the URL only from URL-backed videos; base64-backed videos must be accessed via asBase64(). Same semantics as the TypeScript source in typescript_src/video.ts.","triggerScenarios":"Calling video.asUrl() on a Video instance whose content is base64 data in a project consuming the compiled engine/language_client_typescript/video.js build.","commonSituations":"JavaScript projects (no TS types) loading videos from user uploads (base64) but treating them as URL-backed; legacy code paths using the compiled client; mixing videos fetched from APIs with locally embedded media.","solutions":["Guard with if (video.isUrl()) before calling asUrl()","Use isUrl() to choose between asUrl() and asBase64() handling","Pass URL-form video content when you need URL access later","Upgrade to the TypeScript client if possible to get static typing help"],"exampleFix":"// before\nconst url = video.asUrl();\n// after\nconst url = video.isUrl() ? video.asUrl() : null;","handlingStrategy":"type-guard","validationCode":"if (typeof video.isUrl !== \"function\" || !video.isUrl()) {\n  // not URL-backed; use asBase64() path\n}","typeGuard":"function isUrlVideo(video) { return video && typeof video.isUrl === \"function\" && video.isUrl() === true; }","tryCatchPattern":"let url = null;\ntry {\n  url = video.asUrl();\n} catch (e) {\n  if (!/not a URL/.test(e.message)) throw e;\n}","preventionTips":["Guard with video.isUrl() in all JS call sites","Document the expected storage type where videos enter your system","Consider consuming the TypeScript client for static safety"],"tags":["javascript","video","multimodal","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-14T05:17:10.506Z"}