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

dataSource setter in src/components/FlameGraph/flame-graph-class.js throws when format is falsy. The component must know whether to run genFramesFromLineData or genFramesFromTreeData, so an absent format is rejected up front.

Source

Thrown at labs/arthas-jfr-frontend/src/components/FlameGraph/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

  1. Include format: 'line' or format: 'tree' in the dataSource.
  2. Default the field from your data shape before assigning.
  3. Guard at the call site so an incomplete dataSource is never assigned.

Example fix

// before
el.dataSource = payload; // payload has no format

// after
el.dataSource = { format: detectFormat(payload), ...payload };
Defensive patterns

Strategy: type-guard

Validate before calling

if (!dataSource || !dataSource.format) throw new Error('format required');
el.dataSource = dataSource;

Type guard

function hasFormat(ds) { return !!ds && !!ds.format; }

Prevention

When it happens

Trigger: Assigning a dataSource object without a format key; format set to '' , null, or undefined.

Common situations: Payload schema changed upstream; partial object spread omitted format.

Related errors


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