eyaltoledano/claude-task-master · error · Error
Format must be a string
Error message
Format must be a string
What it means
ProgressBarFactory.createBar() validates that the bar format is a string before handing it to multibar.create, since cli-progress formats are template strings. Non-string formats (undefined, objects) would silently corrupt rendering, so it throws immediately.
Source
Thrown at src/progress/tracker-ui.js:19
import chalk from 'chalk';
/**
* Factory for creating progress bar elements
*/
class ProgressBarFactory {
constructor(multibar) {
if (!multibar) {
throw new Error('Multibar instance is required');
}
this.multibar = multibar;
}
/**
* Creates a progress bar with the given format
*/
createBar(format, payload = {}) {
if (typeof format !== 'string') {
throw new Error('Format must be a string');
}
const bar = this.multibar.create(
1, // total
1, // current
{},
{
format,
barsize: 1,
hideCursor: true,
clearOnComplete: false
}
);
bar.update(1, payload);
return bar;
}
View on GitHub (pinned to c0c98d367c)
Solutions
- Pass a string format, e.g. createBar('{bar} {percentage}%').
- Check that any format constant you reference is actually imported and defined.
- Coerce/validate dynamic formats: typeof fmt === 'string' ? fmt : DEFAULT_FORMAT.
- Trace whether createHeader/createRow/createBorder received a bad argument upstream.
Example fix
// before
// factory.createBar(SOME_FORMAT) // SOME_FORMAT undefined
// after
// import { SOME_FORMAT } from './formats.js'; // ensure defined
// factory.createBar(SOME_FORMAT || '{bar} {percentage}%'); Defensive patterns
Strategy: type-guard
Validate before calling
function safeCreateBar(factory, format, payload) {
const fmt = typeof format === 'string' && format.length ? format : '{bar} {percentage}% | {value}/{total}';
return factory.createBar(fmt, payload);
} Type guard
function isBarFormat(f) {
return typeof f === 'string' && f.length > 0;
} Try / catch
try {
factory.createBar(format);
} catch (e) {
if (e.message === 'Format must be a string') {
return factory.createBar(DEFAULT_BAR_FORMAT);
}
throw e;
} Prevention
- Verify format constants are imported and defined before use
- Coerce dynamic format values with String() or fallback defaults
- Use named exports for formats and lint for unused/undefined identifiers
- Add unit checks that header/row/border helpers receive string formats
When it happens
Trigger: factory.createBar(undefined) or createBar(someObject) — e.g. a format constant not imported/defined, or a config value that isn't a string; called internally by createHeader, createRow, and createBorder.
Common situations: Missing import of a format constant (undefined passed through), building format strings dynamically and getting non-string results, renamed/removed format helpers after a version upgrade.
Understand the failure class
Background: Invalid argument type errors: "must be of type string", "expected X, got Y", and ERR_INVALID_ARG_TYPE explained — this error's family across 15 libraries.
Related errors
- Spinner messages must be an array
- Multibar instance is required
- MFA_VERIFICATION_FAILED
- Failed to initialize services: ${(error as Error).message}
- Invalid format: ${options.format}. Valid formats are: text,
AI-assisted analysis of eyaltoledano/claude-task-master@c0c98d367c (2026-08-29).
Data as JSON: /api/errors/1862f5df3091fae8.
Report an issue: GitHub.