{"record":{"id":"f61b2b92578e89ab","repo":"alibaba/arthas","slug":"illegal-datasource-format-type-must-be-string","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/public/flame-graph/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/public/flame-graph/flame-graph-class.js#L591-L627","documentation":"Thrown by the dataSource setter when dataSource.format is present but typeof is not 'string' (e.g., a number, boolean, object, or array). The component only accepts a string identifier for the format.","triggerScenarios":"Passing { format: 1 } or { format: true }; passing { format: { type: 'line' } }; a numeric enum/constant leaked in from a typed layer that was not converted to a string.","commonSituations":"JSON produced by a serializer that turned format into a non-string; TypeScript/enum value coerced unexpectedly; misconfigured payload builder.","solutions":["Set format to a literal string 'line' or 'tree'.","If the value comes from a variable, coerce with String(x) only after confirming it represents 'line' or 'tree'.","Add a type guard so non-string formats are rejected before reaching the component."],"exampleFix":"// before\nel.dataSource = { format: fmtEnum /* number */, data };\n\n// after\nel.dataSource = { format: fmtEnum === Fmt.Line ? 'line' : 'tree', data };","handlingStrategy":"type-guard","validationCode":"if (typeof dataSource.format !== 'string') {\n  throw new TypeError('dataSource.format must be a string');\n}","typeGuard":"function isStringFormat(ds) { return !!ds && typeof ds.format === 'string'; }","tryCatchPattern":"try { el.dataSource = dataSource; }\ncatch (e) { if (/must be string/.test(e.message)) { el.dataSource = { ...dataSource, format: String(dataSource.format) }; } else throw e; }","preventionTips":["Type dataSource.format as a string literal union in TypeScript.","Coerce enum values to strings at the boundary."],"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"}