{"record":{"id":"54c2b67e16eb0383","repo":"BabylonJS/Babylon.js","slug":"unknown-variant-variant-use-compiled-raw","errorCode":null,"errorMessage":"Unknown variant \"${variant}\". Use: compiled, raw, or beforeMigration.","messagePattern":"Unknown variant \"(.+?)\"\\. Use: compiled, raw, or beforeMigration\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/dev/inspector-v2/src/services/cli/shaderCommandService.ts","lineNumber":71,"sourceCode":"\r\n                let vertexShader: string;\r\n                let fragmentShader: string;\r\n\r\n                switch (variant) {\r\n                    case \"compiled\":\r\n                        vertexShader = effect.vertexSourceCode;\r\n                        fragmentShader = effect.fragmentSourceCode;\r\n                        break;\r\n                    case \"raw\":\r\n                        vertexShader = effect.rawVertexSourceCode;\r\n                        fragmentShader = effect.rawFragmentSourceCode;\r\n                        break;\r\n                    case \"beforeMigration\":\r\n                        vertexShader = effect.vertexSourceCodeBeforeMigration;\r\n                        fragmentShader = effect.fragmentSourceCodeBeforeMigration;\r\n                        break;\r\n                    default:\r\n                        throw new Error(`Unknown variant \"${variant}\". Use: compiled, raw, or beforeMigration.`);\r\n                }\r\n\r\n                return JSON.stringify({ vertexShader, fragmentShader }, null, 2);\r\n            },\r\n        });\r\n\r\n        return {\r\n            dispose: () => {\r\n                registration.dispose();\r\n            },\r\n        };\r\n    },\r\n};\r\n","sourceCodeStart":53,"sourceCodeEnd":85,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/inspector-v2/src/services/cli/shaderCommandService.ts#L53-L85","documentation":"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.","triggerScenarios":"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\".","commonSituations":"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.","solutions":["Pass one of the exact lowercase strings: \"compiled\", \"raw\", or \"beforeMigration\"","Omit the variant argument entirely to get the default \"compiled\" behavior","Fix casing/typos in scripts calling this command (matching is case-sensitive)","Check the command's args help (variant description) for the currently supported list"],"exampleFix":"// before\nconst code = await cli.run(\"get-shader-code\", { uniqueId: \"123\", variant: \"Compiled\" });\n// after\nconst code = await cli.run(\"get-shader-code\", { uniqueId: \"123\", variant: \"compiled\" });","handlingStrategy":"validation","validationCode":"const VALID_VARIANTS = [\"compiled\", \"raw\", \"beforeMigration\"] as const;\nif (variant !== undefined && !VALID_VARIANTS.includes(variant)) {\n    throw new Error(`variant must be one of ${VALID_VARIANTS.join(\", \")}`);\n}","typeGuard":"function isValidVariant(v: string | undefined): v is \"compiled\" | \"raw\" | \"beforeMigration\" {\n    return v === undefined || v === \"compiled\" || v === \"raw\" || v === \"beforeMigration\";\n}","tryCatchPattern":"try {\n    return await cli.run(\"get-shader-code\", { uniqueId, variant });\n} catch (err) {\n    if (String(err).includes(\"Unknown variant\")) {\n        console.error(`Invalid variant \"${variant}\"; use compiled, raw, or beforeMigration.`);\n        return cli.run(\"get-shader-code\", { uniqueId }); // default variant\n    }\n    throw err;\n}","preventionTips":["Use a TypeScript literal-union type (\"compiled\" | \"raw\" | \"beforeMigration\") for the variant in calling code","Omit the variant argument when you want the default compiled output","Keep variant strings lowercase and avoid building them dynamically from user input without validation"],"tags":["cli","argument-validation","shader"],"backgroundTag":"invalid-argument-value","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}