{"record":{"id":"73032ea6108dc5ed","repo":"ssssssss-team/spider-flow","slug":"bad-type-utils-getclass-val","errorCode":null,"errorMessage":"Bad type: ' + utils.getClass(val)","messagePattern":"Bad type: ' \\+ utils\\.getClass\\(val\\)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"spider-flow-web/src/main/resources/static/js/jsontree/jsontree.js","lineNumber":55,"sourceCode":"                case 'number':\r\n                    return 'number';\r\n                \r\n                case 'string':\r\n                    return 'string';\r\n                \r\n                case 'boolean':\r\n                    return 'boolean';\r\n            }\r\n            \r\n            switch(utils.getClass(val)) {\r\n                case '[object Array]':\r\n                    return 'array';\r\n                \r\n                case '[object Object]':\r\n                    return 'object';\r\n            }\r\n            \r\n            throw new Error('Bad type: ' + utils.getClass(val));\r\n        },\r\n        \r\n        /**\r\n         * Applies for each item of list some function\r\n         * and checks for last element of the list\r\n         * \r\n         * @param obj {Object | Array} - a list or a dict with child nodes\r\n         * @param func {Function} - the function for each item\r\n         */\r\n        forEachNode : function(obj, func) {\r\n            var type = utils.getType(obj),\r\n                isLast;\r\n        \r\n            switch (type) {\r\n                case 'array':\r\n                    isLast = obj.length - 1;\r\n                    \r\n                    obj.forEach(function(item, i) {\r","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/ssssssss-team/spider-flow/blob/c799cca99c7d064673dc79e6ef06a08bbc0e292d/spider-flow-web/src/main/resources/static/js/jsontree/jsontree.js#L37-L73","documentation":"jsontree's utils.getType() switches on the result of Object.prototype.toString.call(val) and supports only a fixed set (array, object, etc.). Any value whose class tag is not in the switch reaches the fallback throw, reporting the unrecognized [object ...] class.","triggerScenarios":"Passing a value of an unsupported type into jsontree's tree-building/getType path — e.g. undefined, function, date, regexp, symbol, or a boxed/null edge case — via new Node() or rendering JSON containing such values.","commonSituations":"Feeding the tree raw JavaScript values instead of JSON-parseable data, JSON responses including dates/functions that were not serialized, or a minified/partial build where getType's supported cases diverge from Node.CONSTRUCTORS.","solutions":["Sanitize data before rendering: JSON.parse(JSON.stringify(data)) so only JSON-safe types remain","Replace or map unsupported values (functions, undefined, Dates) to strings or null in preprocessing","Extend the switch in utils.getType (and Node.CONSTRUCTORS) to cover the missing class"],"exampleFix":"// before\nrender(data); // data may contain functions/Dates\n// after\nrender(JSON.parse(JSON.stringify(data, function(k, v) {\n  return typeof v === \"function\" ? String(v) : v;\n})));","handlingStrategy":"validation","validationCode":"var SUPPORTED = [\"[object Boolean]\",\"[object Number]\",\"[object String]\",\"[object Array]\",\"[object Object]\"];\nfunction isRenderable(v) {\n  return v != null && SUPPORTED.indexOf(Object.prototype.toString.call(v)) !== -1;\n}\nif (!isRenderable(data)) data = sanitize(data); // strip/map functions, dates, undefined","typeGuard":"function isPlainJsonValue(v) {\n  var t = Object.prototype.toString.call(v);\n  return [\"[object Array]\",\"[object Object]\",\"[object String]\",\"[object Number]\",\"[object Boolean]\"].indexOf(t) !== -1;\n}","tryCatchPattern":"try {\n  tree.render(data);\n} catch (e) {\n  if (/Bad type:/.test(e.message)) {\n    tree.render(JSON.parse(JSON.stringify(data)));\n  } else { throw e; }\n}","preventionTips":["Only feed JSON-round-trippable data (JSON.parse(JSON.stringify(...))) to jsontree","Explicitly map Dates/functions/undefined to strings or null before rendering","If you control the library, keep utils.getType's cases and Node.CONSTRUCTORS in sync and add a unit test per type"],"tags":["jsontree","type-mismatch","json"],"backgroundTag":"type-mismatch","analyzedSha":"c799cca99c7d064673dc79e6ef06a08bbc0e292d","analyzedAt":"2026-09-08T13:47:08.225Z","contentChangedAt":"2026-09-08T13:47:08.225Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}