BoundaryML/baml · error · Error

Video is not a URL

Error message

Video is not a URL

What it means

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.

Source

Thrown at engine/language_client_typescript/video.js:68

     */
    static async fromUrlAsync(url) {
        const response = await fetch(url);
        const blob = await response.blob();
        return BamlVideo.fromBlob(blob);
    }
    /**
     * Check if the video is stored as a URL
     */
    isUrl() {
        return this.type === "url";
    }
    /**
     * Get the URL of the video if it's stored as a URL
     * @throws Error if the video is not stored as a URL
     */
    asUrl() {
        if (!this.isUrl()) {
            throw new Error("Video is not a URL");
        }
        return this.content;
    }
    /**
     * Get the base64 data and media type if the video is stored as base64
     * @returns [base64Data, mediaType]
     * @throws Error if the video is not stored as base64
     */
    asBase64() {
        if (this.type !== "base64") {
            throw new Error("Video is not base64");
        }
        return [this.content, this.mediaType || ""];
    }
    /**
     * Convert the video to a JSON representation
     */
    toJSON() {

View on GitHub (pinned to bd85ce9dee)

Solutions

  1. Guard with if (video.isUrl()) before calling asUrl()
  2. Use isUrl() to choose between asUrl() and asBase64() handling
  3. Pass URL-form video content when you need URL access later
  4. Upgrade to the TypeScript client if possible to get static typing help

Example fix

// before
const url = video.asUrl();
// after
const url = video.isUrl() ? video.asUrl() : null;
Defensive patterns

Strategy: type-guard

Validate before calling

if (typeof video.isUrl !== "function" || !video.isUrl()) {
  // not URL-backed; use asBase64() path
}

Type guard

function isUrlVideo(video) { return video && typeof video.isUrl === "function" && video.isUrl() === true; }

Try / catch

let url = null;
try {
  url = video.asUrl();
} catch (e) {
  if (!/not a URL/.test(e.message)) throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "is not a compatible type" / "cannot merge" errors: when a value's type doesn't match what the library requires — this error's family across 65 libraries.

Related errors


AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12). Data as JSON: /api/errors/25c6af3f20ab16b9. Report an issue: GitHub.