{"record":{"id":"21f68e5eb907036f","repo":"BabylonJS/Babylon.js","slug":"precision-must-be-a-finite-number-greater-than-0","errorCode":null,"errorMessage":"precision must be a finite number greater than 0.","messagePattern":"precision must be a finite number greater than 0\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/dev/inspector-v2/src/services/cli/screenshotCommandService.ts","lineNumber":69,"sourceCode":"                    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\n                let width: number | undefined;\r\n                if (args.width !== undefined) {\r\n                    width = Number(args.width);\r\n                    if (!Number.isFinite(width) || width <= 0 || !Number.isInteger(width)) {\r\n                        throw new Error(\"width must be a finite positive integer.\");\r\n                    }\r\n                }\r\n\r\n                let height: number | undefined;\r\n                if (args.height !== undefined) {\r\n                    height = Number(args.height);\r\n                    if (!Number.isFinite(height) || height <= 0 || !Number.isInteger(height)) {\r\n                        throw new Error(\"height must be a finite positive integer.\");\r\n                    }\r\n                }\r\n                const screenshotSize = width !== undefined && height !== undefined ? { width, height, precision } : { precision };\r","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/inspector-v2/src/services/cli/screenshotCommandService.ts#L51-L87","documentation":"Thrown by the 'screenshot' command when args.precision is supplied but Number(args.precision) is NaN/Infinity or <= 0. Precision controls screenshot output quality and must be a finite positive number (default is 1 when omitted).","triggerScenarios":"Calling screenshot with precision=\"abc\", 0, -2, Infinity, or any value that fails Number.isFinite(precision) && precision > 0.","commonSituations":"Passing percentage strings like \"90%\" (Number gives NaN); passing 0 expecting 'auto'; unit confusion (passing 100 expecting percent where a multiplier is expected).","solutions":["Pass precision as a positive finite number, e.g. precision: 1 (default) or 0.5 for half quality.","Omit precision to use the default value of 1.","Convert/strip units in scripts before passing (e.g. 90 → 0.9)."],"exampleFix":"// before\nawait execute(\"screenshot\", { precision: \"90%\" });\n// after\nawait execute(\"screenshot\", { precision: 0.9 });","handlingStrategy":"validation","validationCode":"if (args.precision !== undefined) {\n  const p = Number(args.precision);\n  if (!Number.isFinite(p) || p <= 0) throw new RangeError(`precision must be a finite number > 0, got: ${args.precision}`);\n}","typeGuard":"function isValidPrecision(v: unknown): v is number { return typeof v === \"number\" && Number.isFinite(v) && v > 0; }","tryCatchPattern":"try {\n  await screenshot({ precision });\n} catch (e) {\n  if (e instanceof Error && e.message.startsWith(\"precision must be\")) {\n    return screenshot({}); // omit to use default precision 1\n  }\n  throw e;\n}","preventionTips":["Coerce with Number() and validate Number.isFinite before passing.","Never pass strings with units (\"90%\"); pass plain numbers.","Omit precision when the default (1) is acceptable."],"tags":["cli","argument-validation","screenshot"],"backgroundTag":"invalid-numeric-argument","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}