{"record":{"id":"6f67315a82c942bf","repo":"eyaltoledano/claude-task-master","slug":"maxbuffersize-must-be-positive","errorCode":null,"errorMessage":"maxBufferSize must be positive","messagePattern":"maxBufferSize must be positive","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/utils/stream-parser.js","lineNumber":62,"sourceCode":"\t\t\tconfig.estimateTokens || ((text) => Math.ceil(text.length / 4));\n\t\tthis.expectedTotal = config.expectedTotal || 0;\n\t\tthis.fallbackItemExtractor = config.fallbackItemExtractor;\n\t\tthis.itemValidator =\n\t\t\tconfig.itemValidator || StreamParserConfig.defaultItemValidator;\n\t\tthis.maxBufferSize = config.maxBufferSize || DEFAULT_MAX_BUFFER_SIZE;\n\n\t\tthis.validate();\n\t}\n\n\tvalidate() {\n\t\tif (!this.jsonPaths || !Array.isArray(this.jsonPaths)) {\n\t\t\tthrow new Error('jsonPaths is required and must be an array');\n\t\t}\n\t\tif (this.jsonPaths.length === 0) {\n\t\t\tthrow new Error('jsonPaths array cannot be empty');\n\t\t}\n\t\tif (this.maxBufferSize <= 0) {\n\t\t\tthrow new Error('maxBufferSize must be positive');\n\t\t}\n\t\tif (this.expectedTotal < 0) {\n\t\t\tthrow new Error('expectedTotal cannot be negative');\n\t\t}\n\t\tif (this.estimateTokens && typeof this.estimateTokens !== 'function') {\n\t\t\tthrow new Error('estimateTokens must be a function');\n\t\t}\n\t\tif (this.onProgress && typeof this.onProgress !== 'function') {\n\t\t\tthrow new Error('onProgress must be a function');\n\t\t}\n\t\tif (this.onError && typeof this.onError !== 'function') {\n\t\t\tthrow new Error('onError must be a function');\n\t\t}\n\t\tif (\n\t\t\tthis.fallbackItemExtractor &&\n\t\t\ttypeof this.fallbackItemExtractor !== 'function'\n\t\t) {\n\t\t\tthrow new Error('fallbackItemExtractor must be a function');","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/src/utils/stream-parser.js#L44-L80","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nnew StreamParser({ jsonPaths: ['$.items'], maxBufferSize: 0 })\n// after\nnew StreamParser({ jsonPaths: ['$.items'], maxBufferSize: 1024 * 1024 })","handlingStrategy":"validation","validationCode":"function assertConfig(config) {\n  if ('maxBufferSize' in config && (!(typeof config.maxBufferSize === 'number') || config.maxBufferSize <= 0)) {\n    throw new TypeError(`maxBufferSize must be a positive number, got ${config.maxBufferSize}`);\n  }\n  return config;\n}\nnew StreamParser(assertConfig(options));","typeGuard":"function isValidBufferSize(v) {\n  return typeof v === 'number' && Number.isFinite(v) && v > 0;\n}","tryCatchPattern":"try {\n  const parser = new StreamParser(options);\n} catch (err) {\n  if (err.message === 'maxBufferSize must be positive') {\n    options.maxBufferSize = 1024 * 1024;\n    return new StreamParser(options);\n  }\n  throw err;\n}","preventionTips":["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."],"tags":["configuration","validation","constructor"],"backgroundTag":"invalid-configuration-value","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}