BabylonJS/Babylon.js · error · Error

Invalid version:

Error message

Invalid version: 

What it means

Thrown by GLTFFileLoader when the glTF asset's `asset.version` string cannot be parsed into a major/minor version pair by _parseVersion. The loader requires a well-formed version (e.g. "2.0") to select the correct glTF loader. It is thrown during asset header validation, before any loaders are created.

Source

Thrown at packages/dev/loaders/src/glTF/glTFFileLoader.pure.ts:1217

            },
            (reason) => {
                this._endPerformanceCounter("Validate JSON");
                Tools.Warn(`Failed to validate: ${reason.message}`);
                this.onValidatedObservable.clear();
            }
        );
    }

    private _getLoader(loaderData: IGLTFLoaderData): IGLTFLoader {
        const asset = (<any>loaderData.json).asset || {};

        this._log(`Asset version: ${asset.version}`);
        asset.minVersion && this._log(`Asset minimum version: ${asset.minVersion}`);
        asset.generator && this._log(`Asset generator: ${asset.generator}`);

        const version = GLTFFileLoader._parseVersion(asset.version);
        if (!version) {
            throw new Error("Invalid version: " + asset.version);
        }

        if (asset.minVersion !== undefined) {
            const minVersion = GLTFFileLoader._parseVersion(asset.minVersion);
            if (!minVersion) {
                throw new Error("Invalid minimum version: " + asset.minVersion);
            }

            if (GLTFFileLoader._compareVersion(minVersion, { major: 2, minor: 0 }) > 0) {
                throw new Error("Incompatible minimum version: " + asset.minVersion);
            }
        }

        const createLoaders: { [key: number]: (parent: GLTFFileLoader) => IGLTFLoader } = {
            1: GLTFFileLoader._CreateGLTF1Loader,
            2: GLTFFileLoader._CreateGLTF2Loader,
        };

View on GitHub (pinned to 0592b347b8)

Solutions

  1. Open the glTF JSON and set `asset.version` to a valid string like "2.0" or "1.0"
  2. Re-export the asset with a spec-compliant glTF validator/tool (e.g. gltf-pipeline, Blender exporter)
  3. Validate the file with glTF-Validator to catch malformed asset metadata

Example fix

// before
"asset": { "version": "v2" }
// after
"asset": { "version": "2.0" }
Defensive patterns

Strategy: validation

Validate before calling

function hasValidGltfVersion(json) {
  const v = json?.asset?.version;
  return typeof v === 'string' && /^\d+\.\d+$/.test(v.trim());
}
if (!hasValidGltfVersion(gltfJson)) throw new Error('asset.version missing or malformed');

Type guard

function hasValidGltfVersion(json) {
  return typeof (json as any)?.asset?.version === 'string' && /^\d+\.\d+$/.test((json as any).asset.version);
}

Try / catch

try {
  await loader.loadAsync(url);
} catch (e) {
  if (e.message?.startsWith('Invalid version:')) {
    console.error('glTF asset.version is malformed:', e.message);
  }
}

Prevention

When it happens

Trigger: Loading a .gltf/.glb whose JSON `asset.version` is missing, empty, or not in `<major>.<minor>` numeric form (e.g. "two point zero", "2", "v2.0").

Common situations: Hand-authored or tool-corrupted glTF JSON; files exported by broken converters; manually edited asset blocks where the version field was removed or mistyped.

Related errors


AI-assisted analysis of BabylonJS/Babylon.js@0592b347b8 (2026-08-30). Data as JSON: /api/errors/139d3117b503804f. Report an issue: GitHub.