alibaba/arthas · error · Error

Illegal dataSource format type, must be string

Error message

Illegal dataSource format type, must be string

What it means

dataSource setter rejects a non-string format value. After confirming format is truthy it checks typeof !== 'string', so numbers/booleans/objects are refused before toLowerCase() is attempted.

Source

Thrown at labs/arthas-jfr-frontend/src/components/FlameGraph/flame-graph-class.js:609

  }

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

View on GitHub (pinned to 21cf2e9ba5)

Solutions

  1. Provide format as the string 'line' or 'tree'.
  2. Coerce non-string sources with String() after validating meaning.
  3. Add a type guard at the boundary.

Example fix

// before
el.dataSource = { format: fmtCode /* number */, data };

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

Strategy: type-guard

Validate before calling

if (typeof dataSource.format !== 'string') throw new TypeError('format must be string');

Type guard

function isStringFormat(ds) { return !!ds && typeof ds.format === 'string'; }

Prevention

When it happens

Trigger: Passing { format: 0 } or { format: { name: 'line' } }; a numeric enum leaking through.

Common situations: Type coercion across a serialization boundary; enum-to-string mapping forgotten.

Related errors


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