{"record":{"id":"f5cb34fa97aba70e","repo":"pentaho/pentaho-kettle","slug":"can-t-fill-a-sorted-list","errorCode":null,"errorMessage":"Can't fill a sorted list.","messagePattern":"Can't fill a sorted list\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"plugins/core-ui/src/main/resources/app/pentaho/lang/SortedList.js","lineNumber":171,"sourceCode":"          left = i + 1;\n        } else if(comparison > 0) {\n          right = i - 1;\n        } else {\n          return i;\n        }\n      }\n\n      // two's complement operation being used to\n      // return (x+1)*-1 in a hackish way\n      return ~left;\n    },\n\n    copyWithin: function() {\n      throw new Error(\"Can't copy within a sorted list.\");\n    },\n\n    fill: function() {\n      throw new Error(\"Can't fill a sorted list.\");\n    },\n\n    reverse: function() {\n      throw new Error(\"Can't reverse a sorted list.\");\n    },\n\n    unshift: function() {\n      throw new Error(\"Can't do a indexed insert in a sorted list.\");\n    },\n\n    insert: function() {\n      throw new Error(\"Can't do a indexed insert in a sorted list.\");\n    },\n\n    replace: function() {\n      throw new Error(\"Can't do a indexed replace in a sorted list.\");\n    },\n","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/core-ui/src/main/resources/app/pentaho/lang/SortedList.js#L153-L189","documentation":"SortedList.fill throws because overwriting arbitrary positions with a single value (Array.prototype.fill semantics) would violate the list's sorted-order invariant. The method is intentionally implemented as unsupported on sorted lists.","triggerScenarios":"Any call to sortedList.fill(value, start, end), directly or through array-generic helper functions.","commonSituations":"Array-generic utilities applied to a sorted list; initializing slots with a default value using code written for plain Lists/arrays.","solutions":["Pre-populate a plain array then construct the SortedList from it","Use add/addN to insert values so they are placed in sorted order","Convert to a plain array with toArray() before filling"],"exampleFix":"// before\nsortedList.fill(0, 0, 5); // throws\n// after\nvar arr = new Array(5).fill(0);\nvar sl = new SortedList(arr);","handlingStrategy":"try-catch","validationCode":"if (list.isSorted) {\n  throw new TypeError('fill is unsupported on SortedList');\n}","typeGuard":null,"tryCatchPattern":"try {\n  list.fill(v, 0, n);\n} catch (e) {\n  if (String(e.message).indexOf('fill a sorted list') >= 0) {\n    var arr = list.toArray(); arr.fill(v, 0, n); list.clear(); list.addN(arr);\n  } else throw e;\n}","preventionTips":["Avoid Array.prototype.fill semantics on sorted collections","Initialize contents before constructing the SortedList","Use add/addN to control contents"],"tags":["sorted-list","unsupported-operation"],"backgroundTag":"unsupported-operation","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}