alibaba/arthas · error · Error

Illegal dataSource format, must be 'line' or 'tree'

Error message

Illegal dataSource format, must be 'line' or 'tree'

What it means

Thrown by the dataSource setter after lowercasing format, when the value is a string but is neither 'line' nor 'tree' (e.g., 'csv', 'json', 'stacks'). This is the catch-all for unsupported format identifiers even when correctly typed.

Source

Thrown at labs/arthas-jfr-frontend/public/flame-graph/flame-graph-class.js:613

  }

  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') {
      throw new Error('Configuration should be an object');
    }
    this.$configuration = configuration;
  }

  get configuration() {
    return this.$configuration;

View on GitHub (pinned to 21cf2e9ba5)

Solutions

  1. Map the source format name to 'line' or 'tree' before assignment.
  2. For flat stack-sample strings use 'line'; for nested node trees use 'tree'.
  3. Whitelist allowed values at the call site so invalid names never reach the component.

Example fix

// before
el.dataSource = { format: 'json', data };

// after
el.dataSource = { format: 'tree', data };
Defensive patterns

Strategy: validation

Validate before calling

const f = dataSource.format.toLowerCase();
if (f !== 'line' && f !== 'tree') {
  throw new Error(`unsupported format ${f}; expected line|tree`);
}

Type guard

function isValidFormat(ds) {
  const f = ds && typeof ds.format === 'string' ? ds.format.toLowerCase() : '';
  return f === 'line' || f === 'tree';
}

Prevention

When it happens

Trigger: Passing { format: 'json' } or { format: 'stacks' }; a typo such as 'tre' or 'linel'; assuming the component supports a format name from a different flame-graph library.

Common situations: Migrating from another profiler UI whose format names differ; payload built from a user-facing dropdown whose labels do not match 'line'/'tree'.

Related errors


AI-assisted analysis of alibaba/arthas@21cf2e9ba5 (2026-08-14). Data as JSON: /api/errors/870b122fb3662263. Report an issue: GitHub.