{"record":{"id":"e52db798a5bc4282","repo":"BabylonJS/Babylon.js","slug":"camerauniqueid-must-be-a-number","errorCode":null,"errorMessage":"cameraUniqueId must be a number.","messagePattern":"cameraUniqueId must be a number\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/dev/inspector-v2/src/services/cli/screenshotCommandService.ts","lineNumber":53,"sourceCode":"                    name: \"precision\",\r\n                    description: \"Resolution multiplier (e.g. 2 for double resolution). Defaults to 1.\",\r\n                    required: false,\r\n                },\r\n            ],\r\n            executeAsync: async (args) => {\r\n                const scene = sceneContext.currentScene;\r\n                if (!scene) {\r\n                    throw new Error(\"No active scene.\");\r\n                }\r\n\r\n                const engine = scene.getEngine();\r\n\r\n                // Resolve camera: explicit uniqueId, or active/frame-graph camera.\r\n                let camera;\r\n                if (args.cameraUniqueId) {\r\n                    const cameraId = parseInt(args.cameraUniqueId, 10);\r\n                    if (isNaN(cameraId)) {\r\n                        throw new Error(\"cameraUniqueId must be a number.\");\r\n                    }\r\n                    camera = scene.cameras.find((c) => c.uniqueId === cameraId);\r\n                    if (!camera) {\r\n                        throw new Error(`No camera found with uniqueId ${cameraId}.`);\r\n                    }\r\n                } else {\r\n                    camera = scene.frameGraph ? FrameGraphUtils.FindMainCamera(scene.frameGraph) : scene.activeCamera;\r\n                }\r\n\r\n                if (!camera) {\r\n                    throw new Error(\"No camera available for screenshot.\");\r\n                }\r\n\r\n                const precision = args.precision !== undefined ? Number(args.precision) : 1;\r\n                if (!Number.isFinite(precision) || precision <= 0) {\r\n                    throw new Error(\"precision must be a finite number greater than 0.\");\r\n                }\r\n\r","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/inspector-v2/src/services/cli/screenshotCommandService.ts#L35-L71","documentation":"Thrown by the 'screenshot' command when args.cameraUniqueId is provided but cannot be parsed by parseInt(…, 10). Only fully numeric strings are accepted; anything else (letters, empty string, hex notation) yields NaN and triggers this error.","triggerScenarios":"Calling screenshot with cameraUniqueId=\"cam1\", \"\", \"0x10\", or any non-decimal value while the argument is truthy.","commonSituations":"Passing a camera name instead of its uniqueId; copying an object reference or label from the scene explorer; a script interpolating an undefined variable into the string.","solutions":["Pass the camera's numeric uniqueId as a decimal string (find it via a scene query command).","Omit cameraUniqueId entirely to let the command auto-resolve the active/frame-graph camera.","Trim/normalize the value before passing it; leading/trailing spaces are tolerated by parseInt but other characters are not."],"exampleFix":"// before\nawait execute(\"screenshot\", { cameraUniqueId: \"mainCamera\" });\n// after\nawait execute(\"screenshot\", { cameraUniqueId: \"7\" });","handlingStrategy":"validation","validationCode":"if (args.cameraUniqueId != null && Number.isNaN(Number.parseInt(args.cameraUniqueId, 10))) throw new TypeError(`cameraUniqueId must be a decimal number, got: ${JSON.stringify(args.cameraUniqueId)}`);","typeGuard":"function isNumericId(v: unknown): v is string { return typeof v === \"string\" && /^-?\\d+$/.test(v.trim()); }","tryCatchPattern":"try {\n  await screenshot({ cameraUniqueId: camId });\n} catch (e) {\n  if (e instanceof Error && e.message === \"cameraUniqueId must be a number.\") {\n    return screenshot({}); // fall back to active camera\n  }\n  throw e;\n}","preventionTips":["Use numeric uniqueIds, not camera names/labels.","Resolve ids via a scene query command before passing them.","Omit cameraUniqueId when the active camera is acceptable."],"tags":["cli","argument-validation","camera"],"backgroundTag":"invalid-numeric-argument","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}