alibaba/arthas · error · Error
Should specify the format of dataSource: 'line' or 'tree'
Error message
Should specify the format of dataSource: 'line' or 'tree'
What it means
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.
Source
Thrown at labs/arthas-jfr-frontend/public/flame-graph/flame-graph-class.js:606
set downward(downward) {
this.toggleAttribute('downward', !!downward);
}
static get observedAttributes() {
return ['width', 'height', 'downward'];
}
attributeChangedCallback(name, oldVal, newVal) {
if (!this.$dataSource || oldVal === newVal) {
return;
}
this.render(true, false);
}
set dataSource(dataSource) {
if (!dataSource.format) {
throw new Error("Should specify the format of dataSource: 'line' or 'tree'");
}
if (typeof dataSource.format !== 'string') {
throw new Error('Illegal dataSource format type, must be string');
}
let format = dataSource.format.toLowerCase();
if ('line' !== format && 'tree' !== format) {
throw new Error("Illegal dataSource format, must be 'line' or 'tree'");
}
this.$dataSource = dataSource;
this.render(true, true);
}
get dataSource() {
return this.$dataSource;
}
set configuration(configuration) {
if (typeof configuration !== 'object') {View on GitHub (pinned to 21cf2e9ba5)
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).
Example fix
// before
el.dataSource = { children: [...] };
// after
el.dataSource = { format: 'tree', children: [...] }; Defensive patterns
Strategy: type-guard
Validate before calling
if (!dataSource || !dataSource.format) {
throw new Error('dataSource.format is required (\'line\' or \'tree\')');
}
el.dataSource = dataSource; Type guard
function hasFormat(ds) {
return !!ds && ds.format !== undefined && ds.format !== null && ds.format !== '';
} Try / catch
try { el.dataSource = dataSource; }
catch (e) { if (/Should specify the format/.test(e.message)) { /* set default */ el.dataSource = { ...dataSource, format: 'tree' }; } else throw e; } Prevention
- Make format a required field in your dataSource type.
- Default format from the data shape at the loader boundary.
When it happens
Trigger: Assigning element.dataSource = { values: [...] } with no format key; passing an object whose format is '' or null; spreading a partial config that omits format.
Common situations: 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.
Related errors
- Unsupported dataSource format ${format}
- Illegal dataSource format, must be 'line' or 'tree'
- Unsupported dataSource format ${format}
- Should specify the format of dataSource: 'line' or 'tree'
- Illegal dataSource format, must be 'line' or 'tree'
AI-assisted analysis of alibaba/arthas@21cf2e9ba5 (2026-08-14).
Data as JSON: /api/errors/319565e4ae76ba67.
Report an issue: GitHub.