pentaho/pentaho-kettle · error · Error
Can't reverse a sorted list.
Error message
Can't reverse a sorted list.
What it means
Mutation guard on the SortedList prototype in the Pentaho client UI: reverse() was called on a list that maintains sort order invariantly. All order-destroying operations (copyWithin, fill, reverse, unshift, indexed insert) throw to preserve the sorted invariant.
Solutions
- Iterate the list backwards instead of mutating it
- Create a new SortedList with an inverted comparer for descending order
- Copy to a plain array/Array and reverse that copy
Example fix
// before sortedList.reverse(); // throws // after for (var i = sortedList.count - 1; i >= 0; i--) process(sortedList.at(i));
Defensive patterns
Strategy: try-catch
Validate before calling
if (list.isSorted) {
throw new TypeError('reverse is unsupported on SortedList');
} Try / catch
try {
list.reverse();
} catch (e) {
if (String(e.message).indexOf('reverse a sorted list') >= 0) {
for (var i = list.count - 1; i >= 0; i--) process(list.at(i));
} else throw e;
} Prevention
- Iterate backwards instead of reversing in place
- Build a new SortedList with an inverted comparer for descending order
- Convert to a plain array before reversing
When it happens
Trigger: Any call to sortedList.reverse(), directly or via array-generic code that reverses in place.
Common situations: Trying to display a sorted list in descending order; porting List code to SortedList; array-generic helpers iterating/reversing collections.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- Can't copy within a sorted list.
- Can't do a indexed insert in a sorted list.
- Can't do a indexed replace in a sorted list.
- Can't fill a sorted list.
- Append file in repository is not possible
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/83f45d83e9ab66df.
Report an issue: GitHub.
Appendix: source
Thrown at plugins/core-ui/src/main/resources/app/pentaho/lang/SortedList.js:175
return i;
}
}
// two's complement operation being used to
// return (x+1)*-1 in a hackish way
return ~left;
},
copyWithin: function() {
throw new Error("Can't copy within a sorted list.");
},
fill: function() {
throw new Error("Can't fill a sorted list.");
},
reverse: function() {
throw new Error("Can't reverse a sorted list.");
},
unshift: function() {
throw new Error("Can't do a indexed insert in a sorted list.");
},
insert: function() {
throw new Error("Can't do a indexed insert in a sorted list.");
},
replace: function() {
throw new Error("Can't do a indexed replace in a sorted list.");
},
splice: function() {
if(arguments.length > 2) {
throw new Error("Can't do a indexed insert in a sorted list.");
}View on GitHub (pinned to f3058517a1)