{"record":{"id":"319565e4ae76ba67","repo":"alibaba/arthas","slug":"should-specify-the-format-of-datasource-line-or","errorCode":null,"errorMessage":"Should specify the format of dataSource: 'line' or 'tree'","messagePattern":"Should specify the format of dataSource: 'line' or 'tree'","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"labs/arthas-jfr-frontend/public/flame-graph/flame-graph-class.js","lineNumber":606,"sourceCode":"\n  set downward(downward) {\n    this.toggleAttribute('downward', !!downward);\n  }\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') {","sourceCodeStart":588,"sourceCodeEnd":624,"githubUrl":"https://github.com/alibaba/arthas/blob/21cf2e9ba52b305290be7223b980ff504bb9cb5b/labs/arthas-jfr-frontend/public/flame-graph/flame-graph-class.js#L588-L624","documentation":"Thrown by the dataSource setter when the passed object has a falsy format field (undefined, null, empty string, 0). The component requires callers to explicitly declare whether the payload is 'line' or 'tree' structured data so it can pick the correct frame generator.","triggerScenarios":"Assigning element.dataSource = { values: [...] } with no format key; passing an object whose format is '' or null; spreading a partial config that omits format.","commonSituations":"Refactor that renamed the format field; backend payload shape changed and no longer includes format; copy-pasting a dataSource literal from docs that used a different field name.","solutions":["Add format: 'line' or format: 'tree' to the dataSource object before assignment.","If line data (stack samples as repeated strings), use format: 'line'; if hierarchical nodes, use format: 'tree'.","Validate the dataSource shape at the call site before assigning (see defense)."],"exampleFix":"// before\nel.dataSource = { children: [...] };\n\n// after\nel.dataSource = { format: 'tree', children: [...] };","handlingStrategy":"type-guard","validationCode":"if (!dataSource || !dataSource.format) {\n  throw new Error('dataSource.format is required (\\'line\\' or \\'tree\\')');\n}\nel.dataSource = dataSource;","typeGuard":"function hasFormat(ds) {\n  return !!ds && ds.format !== undefined && ds.format !== null && ds.format !== '';\n}","tryCatchPattern":"try { el.dataSource = dataSource; }\ncatch (e) { if (/Should specify the format/.test(e.message)) { /* set default */ el.dataSource = { ...dataSource, format: 'tree' }; } else throw e; }","preventionTips":["Make format a required field in your dataSource type.","Default format from the data shape at the loader boundary."],"tags":["flame-graph","web-component","data-validation"],"backgroundTag":null,"analyzedSha":"21cf2e9ba52b305290be7223b980ff504bb9cb5b","analyzedAt":"2026-08-14T00:57:07.243Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}