{"record":{"id":"414b48d2fe00499d","repo":"eyaltoledano/claude-task-master","slug":"jsonpaths-is-required-and-must-be-an-array","errorCode":null,"errorMessage":"jsonPaths is required and must be an array","messagePattern":"jsonPaths is required and must be an array","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/utils/stream-parser.js","lineNumber":56,"sourceCode":"class StreamParserConfig {\n\tconstructor(config = {}) {\n\t\tthis.jsonPaths = config.jsonPaths;\n\t\tthis.onProgress = config.onProgress;\n\t\tthis.onError = config.onError;\n\t\tthis.estimateTokens =\n\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');","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/src/utils/stream-parser.js#L38-L74","documentation":"StreamParser.validate enforces its constructor contract: jsonPaths must be an array (it defines which JSON fields are streamed out of a larger stream). It throws when jsonPaths is undefined/null or not an array, catching misconfigured parsers before any stream processing starts.","triggerScenarios":"Constructing the StreamParser with no jsonPaths option, passing a string like 'data.items' instead of ['data.items'], or passing null/undefined from a config lookup.","commonSituations":"Config that stores comma-separated path strings instead of arrays; caller confusing a single path string with the required array; JSON schema/config migrations dropping the field.","solutions":["Pass an array: new StreamParser({ jsonPaths: ['choices.0.delta.content'], ... })","Wrap single paths in an array: Array.isArray(p) ? p : [p]","Fix config loading so jsonPaths is parsed into an array (split(',') if it is a string)."],"exampleFix":"// before\nnew StreamParser({ jsonPaths: 'delta.text' });\n// after\nnew StreamParser({ jsonPaths: ['delta.text'] });","handlingStrategy":"validation","validationCode":"if (!Array.isArray(jsonPaths) || jsonPaths.length === 0) {\n  throw new TypeError('jsonPaths must be a non-empty array of strings');\n}\nconst parser = new StreamParser({ jsonPaths, ...opts });","typeGuard":"const isNonEmptyStringArray = (v) => Array.isArray(v) && v.length > 0 && v.every((s) => typeof s === 'string');","tryCatchPattern":"try {\n  const parser = new StreamParser({ jsonPaths });\n} catch (err) {\n  if (err.message === 'jsonPaths is required and must be an array') {\n    const parser = new StreamParser({ jsonPaths: Array.isArray(jsonPaths) ? jsonPaths : [String(jsonPaths)] });\n  } else throw err;\n}","preventionTips":["Wrap single path strings in arrays before constructing the parser","Validate config shape (array of strings) at load time","Document the constructor contract in your wrapper's JSDoc"],"tags":["validation","streaming","configuration"],"backgroundTag":"invalid-argument-type","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}