{"record":{"id":"77fb817399ec35f3","repo":"BabylonJS/Babylon.js","slug":"uniqueid-must-be-a-number","errorCode":null,"errorMessage":"uniqueId must be a number.","messagePattern":"uniqueId must be a number\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/dev/inspector-v2/src/services/cli/entityQueryService.ts","lineNumber":125,"sourceCode":"                throw new Error(\"No active scene.\");\r\n            }\r\n\r\n            const entities = collection.getEntities(scene);\r\n            if (!entities) {\r\n                return JSON.stringify([], null, 2);\r\n            }\r\n\r\n            if (!args.uniqueId) {\r\n                return JSON.stringify(\r\n                    entities.map((e) => collection.getSummary(e)),\r\n                    null,\r\n                    2\r\n                );\r\n            }\r\n\r\n            const id = parseInt(args.uniqueId, 10);\r\n            if (isNaN(id)) {\r\n                throw new Error(\"uniqueId must be a number.\");\r\n            }\r\n\r\n            const entity = entities.find((e) => collection.getUniqueId(e) === id);\r\n            if (!entity) {\r\n                throw new Error(`No ${collection.id.replace(\"query-\", \"\")} found with uniqueId ${id}.`);\r\n            }\r\n\r\n            return JSON.stringify(collection.serialize ? collection.serialize(entity) : collection.getSummary(entity), null, 2);\r\n        },\r\n    };\r\n}\r\n\r\n/**\r\n * Service that registers CLI commands for querying scene entities by uniqueId.\r\n * When uniqueId is omitted, returns a summary list of all entities of that type.\r\n */\r\nexport const EntityQueryServiceDefinition: ServiceDefinition<[], [IBridgeCommandRegistry, ISceneContext]> = {\r\n    friendlyName: \"Entity Query Service\",\r","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/inspector-v2/src/services/cli/entityQueryService.ts#L107-L143","documentation":"Thrown by the inspector's make-query CLI command when the uniqueId argument cannot be parsed as a base-10 integer (parseInt returns NaN). The command requires a numeric entity uniqueId to look up an entity in a registered query collection. It is an argument-validation guard before any entity lookup happens.","triggerScenarios":"Calling the 'make-query' CLI command with a missing, empty, or non-numeric args.uniqueId (e.g. \"abc\", \"\", \"12.5.3\", or whitespace).","commonSituations":"Copy-pasting an entity name instead of its uniqueId; an AI/CLI agent hallucinating an id; passing a hex id like \"0x1F\" that parseInt(…,10) rejects; forgetting the argument entirely in scripted invocations.","solutions":["Pass the numeric uniqueId of the entity, e.g. execute make-query with uniqueId \"42\".","Verify the id with a list/query command (the collection's summary output includes uniqueIds) before invoking make-query.","Strip non-numeric prefixes from the id before passing it; note parseInt(…,10) only accepts decimal digits (optionally signed)."],"exampleFix":"// before\nexecute(\"make-query\", { uniqueId: \"mesh-42\" });\n// after\nexecute(\"make-query\", { uniqueId: \"42\" });","handlingStrategy":"validation","validationCode":"const parsed = Number.parseInt(args.uniqueId, 10);\nif (Number.isNaN(parsed)) throw new TypeError(`uniqueId must be a decimal number, got: ${JSON.stringify(args.uniqueId)}`);","typeGuard":"function isValidUniqueId(v: unknown): v is string { return typeof v === \"string\" && /^-?\\d+$/.test(v.trim()); }","tryCatchPattern":"try {\n  await makeQuery(args);\n} catch (e) {\n  if (e instanceof Error && e.message === \"uniqueId must be a number.\") {\n    return listEntities(); // guide user to valid ids\n  }\n  throw e;\n}","preventionTips":["Always fetch uniqueIds from a list/query command, never hand-type them.","Validate numeric CLI args with a regex or Number.isInteger before invoking.","Strip names/prefixes out of id fields at the call site."],"tags":["cli","argument-validation","nan"],"backgroundTag":"invalid-numeric-argument","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}