BabylonJS/Babylon.js · error

Unknown variant "${variant}". Use: compiled, raw, or beforeM

Error message

Unknown variant "${variant}". Use: compiled, raw, or beforeMigration.

What it means

The `get-shader-code` CLI command accepts a `variant` argument restricted to exactly three values: "compiled" (final GLSL after processing), "raw" (unprocessed source), and "beforeMigration" (pre-WGSL-migration source). Any other string hits the switch's default branch and throws this error.

Source

Thrown at packages/dev/inspector-v2/src/services/cli/shaderCommandService.ts:71

                let vertexShader: string;
                let fragmentShader: string;

                switch (variant) {
                    case "compiled":
                        vertexShader = effect.vertexSourceCode;
                        fragmentShader = effect.fragmentSourceCode;
                        break;
                    case "raw":
                        vertexShader = effect.rawVertexSourceCode;
                        fragmentShader = effect.rawFragmentSourceCode;
                        break;
                    case "beforeMigration":
                        vertexShader = effect.vertexSourceCodeBeforeMigration;
                        fragmentShader = effect.fragmentSourceCodeBeforeMigration;
                        break;
                    default:
                        throw new Error(`Unknown variant "${variant}". Use: compiled, raw, or beforeMigration.`);
                }

                return JSON.stringify({ vertexShader, fragmentShader }, null, 2);
            },
        });

        return {
            dispose: () => {
                registration.dispose();
            },
        };
    },
};

View on GitHub (pinned to 0592b347b8)

Solutions

  1. Pass one of the exact lowercase strings: "compiled", "raw", or "beforeMigration"
  2. Omit the variant argument entirely to get the default "compiled" behavior
  3. Fix casing/typos in scripts calling this command (matching is case-sensitive)
  4. Check the command's args help (variant description) for the currently supported list

Example fix

// before
const code = await cli.run("get-shader-code", { uniqueId: "123", variant: "Compiled" });
// after
const code = await cli.run("get-shader-code", { uniqueId: "123", variant: "compiled" });
Defensive patterns

Strategy: validation

Validate before calling

const VALID_VARIANTS = ["compiled", "raw", "beforeMigration"] as const;
if (variant !== undefined && !VALID_VARIANTS.includes(variant)) {
    throw new Error(`variant must be one of ${VALID_VARIANTS.join(", ")}`);
}

Type guard

function isValidVariant(v: string | undefined): v is "compiled" | "raw" | "beforeMigration" {
    return v === undefined || v === "compiled" || v === "raw" || v === "beforeMigration";
}

Try / catch

try {
    return await cli.run("get-shader-code", { uniqueId, variant });
} catch (err) {
    if (String(err).includes("Unknown variant")) {
        console.error(`Invalid variant "${variant}"; use compiled, raw, or beforeMigration.`);
        return cli.run("get-shader-code", { uniqueId }); // default variant
    }
    throw err;
}

Prevention

When it happens

Trigger: Calling get-shader-code with a variant string other than "compiled", "raw", or "beforeMigration" — typos, wrong casing (e.g. "Compiled", "COMPILED"), or invented names like "vertex" or "source".

Common situations: Typo or wrong casing in a CLI call or automation script; copying an argument from another tool's API; assuming case-insensitive matching; outdated scripts using variant names from an older inspector version.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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