eyaltoledano/claude-task-master · error
maxBufferSize must be positive
Error message
maxBufferSize must be positive
What it means
The StreamParser constructor rejects configurations where maxBufferSize is zero or negative. This option caps how many bytes of streamed text may be buffered before parsing, so a non-positive value would make every chunk fail validation. It is thrown synchronously during construction, before any streaming begins.
Source
Thrown at src/utils/stream-parser.js:62
config.estimateTokens || ((text) => Math.ceil(text.length / 4));
this.expectedTotal = config.expectedTotal || 0;
this.fallbackItemExtractor = config.fallbackItemExtractor;
this.itemValidator =
config.itemValidator || StreamParserConfig.defaultItemValidator;
this.maxBufferSize = config.maxBufferSize || DEFAULT_MAX_BUFFER_SIZE;
this.validate();
}
validate() {
if (!this.jsonPaths || !Array.isArray(this.jsonPaths)) {
throw new Error('jsonPaths is required and must be an array');
}
if (this.jsonPaths.length === 0) {
throw new Error('jsonPaths array cannot be empty');
}
if (this.maxBufferSize <= 0) {
throw new Error('maxBufferSize must be positive');
}
if (this.expectedTotal < 0) {
throw new Error('expectedTotal cannot be negative');
}
if (this.estimateTokens && typeof this.estimateTokens !== 'function') {
throw new Error('estimateTokens must be a function');
}
if (this.onProgress && typeof this.onProgress !== 'function') {
throw new Error('onProgress must be a function');
}
if (this.onError && typeof this.onError !== 'function') {
throw new Error('onError must be a function');
}
if (
this.fallbackItemExtractor &&
typeof this.fallbackItemExtractor !== 'function'
) {
throw new Error('fallbackItemExtractor must be a function');View on GitHub (pinned to c0c98d367c)
Solutions
- Pass a positive maxBufferSize, e.g. maxBufferSize: 1024 * 1024 for 1 MB.
- If unset intentionally, omit the option so the constructor default applies instead of passing 0.
- Validate config at startup: if (config.maxBufferSize <= 0) throw before constructing the parser.
Example fix
// before
new StreamParser({ jsonPaths: ['$.items'], maxBufferSize: 0 })
// after
new StreamParser({ jsonPaths: ['$.items'], maxBufferSize: 1024 * 1024 }) Defensive patterns
Strategy: validation
Validate before calling
function assertConfig(config) {
if ('maxBufferSize' in config && (!(typeof config.maxBufferSize === 'number') || config.maxBufferSize <= 0)) {
throw new TypeError(`maxBufferSize must be a positive number, got ${config.maxBufferSize}`);
}
return config;
}
new StreamParser(assertConfig(options)); Type guard
function isValidBufferSize(v) {
return typeof v === 'number' && Number.isFinite(v) && v > 0;
} Try / catch
try {
const parser = new StreamParser(options);
} catch (err) {
if (err.message === 'maxBufferSize must be positive') {
options.maxBufferSize = 1024 * 1024;
return new StreamParser(options);
}
throw err;
} Prevention
- Never pass maxBufferSize: 0 explicitly; omit the option to use the default.
- Centralize parser construction in one factory that applies sane defaults.
- Validate numeric config values (> 0, finite) at startup before wiring.
- Add a unit test that constructs the parser with production config.
When it happens
Trigger: new StreamParser({ jsonPaths: [...], maxBufferSize: 0 }) or a negative number (e.g. maxBufferSize: -1), or a config object where maxBufferSize is parsed from an env/CLI string that becomes 0/NaN-like falsy-handled value.
Common situations: Copy-pasting example config with maxBufferSize omitted in a template that defaults it to 0; misreading the option as 'extra buffer above input'; unit tests constructing the parser with empty options objects.
Understand the failure class
Background: "Invalid configuration value" and "Unsupported/Unknown setting value" errors: why libraries reject your config strings, numbers, and types — this error's family across 30 libraries.
Related errors
- Provider name is required
- Project path is required
- Project path must be an absolute path
- MISSING_CONFIGURATION
- INVALID_INPUT
AI-assisted analysis of eyaltoledano/claude-task-master@c0c98d367c (2026-08-29).
Data as JSON: /api/errors/6f67315a82c942bf.
Report an issue: GitHub.