{"record":{"id":"ba90d31d4eb63d0e","repo":"alibaba/arthas","slug":"illegal-datasource-format-type-must-be-string-ba90d3","errorCode":null,"errorMessage":"Illegal dataSource format type, must be string","messagePattern":"Illegal dataSource format type, must be string","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"labs/arthas-jfr-frontend/src/components/FlameGraph/flame-graph-class.js","lineNumber":609,"sourceCode":"  }\n\n  static get observedAttributes() {\n    return ['width', 'height', 'downward'];\n  }\n\n  attributeChangedCallback(name, oldVal, newVal) {\n    if (!this.$dataSource || oldVal === newVal) {\n      return;\n    }\n    this.render(true, false);\n  }\n\n  set dataSource(dataSource) {\n    if (!dataSource.format) {\n      throw new Error(\"Should specify the format of dataSource: 'line' or 'tree'\");\n    }\n    if (typeof dataSource.format !== 'string') {\n      throw new Error('Illegal dataSource format type, must be string');\n    }\n    let format = dataSource.format.toLowerCase();\n    if ('line' !== format && 'tree' !== format) {\n      throw new Error(\"Illegal dataSource format, must be 'line' or 'tree'\");\n    }\n    this.$dataSource = dataSource;\n    this.render(true, true);\n  }\n\n  get dataSource() {\n    return this.$dataSource;\n  }\n\n  set configuration(configuration) {\n    if (typeof configuration !== 'object') {\n      throw new Error('Configuration should be an object');\n    }\n    this.$configuration = configuration;","sourceCodeStart":591,"sourceCodeEnd":627,"githubUrl":"https://github.com/alibaba/arthas/blob/21cf2e9ba52b305290be7223b980ff504bb9cb5b/labs/arthas-jfr-frontend/src/components/FlameGraph/flame-graph-class.js#L591-L627","documentation":"dataSource setter rejects a non-string format value. After confirming format is truthy it checks typeof !== 'string', so numbers/booleans/objects are refused before toLowerCase() is attempted.","triggerScenarios":"Passing { format: 0 } or { format: { name: 'line' } }; a numeric enum leaking through.","commonSituations":"Type coercion across a serialization boundary; enum-to-string mapping forgotten.","solutions":["Provide format as the string 'line' or 'tree'.","Coerce non-string sources with String() after validating meaning.","Add a type guard at the boundary."],"exampleFix":"// before\nel.dataSource = { format: fmtCode /* number */, data };\n\n// after\nel.dataSource = { format: fmtCode === 0 ? 'line' : 'tree', data };","handlingStrategy":"type-guard","validationCode":"if (typeof dataSource.format !== 'string') throw new TypeError('format must be string');","typeGuard":"function isStringFormat(ds) { return !!ds && typeof ds.format === 'string'; }","tryCatchPattern":null,"preventionTips":["Type format as string in TS.","Convert enums to strings before assignment."],"tags":["flame-graph","web-component","type-validation"],"backgroundTag":null,"analyzedSha":"21cf2e9ba52b305290be7223b980ff504bb9cb5b","analyzedAt":"2026-08-14T00:57:07.243Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}