{"record":{"id":"882c6fb1790a4b53","repo":"eyaltoledano/claude-task-master","slug":"jsonpaths-array-cannot-be-empty","errorCode":null,"errorMessage":"jsonPaths array cannot be empty","messagePattern":"jsonPaths array cannot be empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/utils/stream-parser.js","lineNumber":59,"sourceCode":"\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');\n\t\t}\n\t\tif (\n\t\t\tthis.fallbackItemExtractor &&","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/src/utils/stream-parser.js#L41-L77","documentation":"StreamParser.validate also requires jsonPaths to contain at least one entry. An empty array is type-correct but leaves the parser with nothing to extract, so it is rejected explicitly right after the array-type check.","triggerScenarios":"Constructing StreamParser with jsonPaths: [] — e.g. user selected no fields, a filter removed all entries, or config initialized with an empty default.","commonSituations":"UI/config where path selection is optional but the parser is always constructed; building jsonPaths by filtering and ending up with an empty list; env-driven config where the variable is set but parses to [].","solutions":["Provide at least one JSON path in the array, e.g. ['choices.0.delta.content']","Guard the caller: skip constructing the parser (or fall back to default paths) when the selected list is empty","Give config a non-empty default instead of []."],"exampleFix":"// before\nconst paths = selectedFields.filter(Boolean); // may be []\nconst parser = new StreamParser({ jsonPaths: paths });\n// after\nconst paths = selectedFields.filter(Boolean);\nif (paths.length === 0) return null;\nconst parser = new StreamParser({ jsonPaths: paths });","handlingStrategy":"validation","validationCode":"const paths = (selectedPaths || []).filter(Boolean);\nif (paths.length === 0) {\n  throw new TypeError('At least one jsonPath is required to construct StreamParser');\n}","typeGuard":"const hasPaths = (v) => Array.isArray(v) && v.length > 0;","tryCatchPattern":"try {\n  const parser = new StreamParser({ jsonPaths: paths });\n} catch (err) {\n  if (err.message === 'jsonPaths array cannot be empty') {\n    const parser = new StreamParser({ jsonPaths: ['delta.text'] }); // sensible default\n  } else throw err;\n}","preventionTips":["Provide non-empty defaults in config instead of []","Check that filtering/selection logic cannot produce empty path lists before constructing","Make path selection required in your UI/config validation layer"],"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"}