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
- Provide format as the string 'line' or 'tree'.
- Coerce non-string sources with String() after validating meaning.
- 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
- Type format as string in TS.
- Convert enums to strings before assignment.
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
- Illegal dataSource format type, must be string
- Configuration should be an object
- Configuration should be an object
- Unsupported dataSource format ${format}
- Should specify the format of dataSource: 'line' or 'tree'
AI-assisted analysis of alibaba/arthas@21cf2e9ba5 (2026-08-14).
Data as JSON: /api/errors/ba90d31d4eb63d0e.
Report an issue: GitHub.