{"record":{"id":"123c33e28a8bd35e","repo":"apache/hadoop","slug":"is-not-a-number","errorCode":null,"errorMessage":"{} is not a number","messagePattern":"(.+?) is not a number","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/static/json-bignum.js","lineNumber":64,"sourceCode":"    NOT CONTROL.\n*/\n\n/*jslint for */\n\n/*property\n    at, b, call, charAt, f, fromCharCode, hasOwnProperty, message, n, name,\n    prototype, push, r, t, text\n*/\n\n(function(exports) {\n\n  function BigNumber(number) {\n    this.numberStr = number.toString();\n\n    // not a number\n    if (isNaN(parseFloat(this.numberStr)) === true\n        || isFinite(this.numberStr) === false) {\n        throw new Error(number + ' is not a number');\n    }\n  }\n\n  BigNumber.prototype.toString = function() {\n    return this.numberStr;\n  }\n\nexports.JSONParseBigNum = (function () {\n\n\n// This is a function that can parse a JSON text, producing a JavaScript\n// data structure. It is a simple, recursive descent parser. It does not use\n// eval or regular expressions, so it can be used as a model for implementing\n// a JSON parser in other languages.\n\n// We are defining the function inside of another function to avoid creating\n// global variables.\n","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/static/json-bignum.js#L46-L82","documentation":"json-bignum.js (bundled with the HDFS web UIs to parse JSON containing 64-bit numbers) wraps values in BigNumber; the constructor does number.toString() and throws Error(number + ' is not a number') when isNaN(parseFloat(...)) is true or isFinite(...) is false. Anything that does not start with a parseable finite numeric string is rejected at construction time.","triggerScenarios":"new BigNumber(undefined), new BigNumber(null), new BigNumber(''), new BigNumber('abc'), NaN or Infinity — e.g. feeding a missing JSON field (undefined after property access), a null counter, or an unvalidated string into the constructor.","commonSituations":"HDFS web UI JavaScript reading optional fields that the server omits or returns as null; passing user/query parameters straight into BigNumber; empty-string defaults from form inputs.","solutions":["Default and validate before wrapping: treat null/undefined/'' as 0 or skip the value","Gate with Number.isFinite(Number(x)) and only then construct BigNumber(x)","Fix the data producer so numeric fields are always present and numeric in the JSON payload"],"exampleFix":"// before\nconst bn = new BigNumber(json.txid); // undefined when field absent -> throws\n\n// after\nconst raw = json.txid;\nconst bn = new BigNumber(Number.isFinite(Number(raw)) ? raw : 0);","handlingStrategy":"type-guard","validationCode":"function toBigNumber(raw, fallback) {\n  return isBigNumberInput(raw) ? new BigNumber(raw) : new BigNumber(fallback || 0);\n}","typeGuard":"function isBigNumberInput(v) {\n  if (typeof v === 'number') return Number.isFinite(v);\n  if (typeof v !== 'string') return false;\n  return /^-?\\d+(\\.\\d+)?([eE][+-]?\\d+)?$/.test(v.trim());\n}","tryCatchPattern":"try {\n  var bn = new BigNumber(value);\n} catch (e) {\n  if (/is not a number$/.test(e.message)) { /* default or skip */ }\n  else throw e;\n}","preventionTips":["Never pass unchecked JSON fields or query params to BigNumber","Default null/undefined/'' before wrapping","Fix producers to always emit numeric values for numeric fields"],"tags":["javascript","json","numeric","validation","hdfs-web-ui"],"backgroundTag":"invalid-numeric-input","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}