pentaho/pentaho-kettle · error · TypeError
TypeError
Error message
TypeError
What it means
The ES5 Array.prototype.indexOf polyfill implements the spec: if `this` is null or undefined (the method is called on null/undefined or as a bare function), it throws a bare TypeError, per ECMA-262 15.4.4.14.
Solutions
- Guard the receiver: if(arr) idx = arr.indexOf(x).
- When using indexOf.call, pass a real array-like object as the first argument.
- Default null receivers to an empty array before searching.
Example fix
// before var i = Array.prototype.indexOf.call(maybeNull, item); // after var i = maybeNull ? maybeNull.indexOf(item) : -1;
Defensive patterns
Strategy: type-guard
Validate before calling
if (arr == null) return -1; var idx = arr.indexOf(item);
Type guard
function isSearchable(x) { return x != null && typeof x.length === 'number'; } Try / catch
try { i = arr.indexOf(item); } catch (e) { if (e instanceof TypeError) { i = -1; } else throw e; } Prevention
- Null-check arrays before generic method calls like indexOf.call.
- Default null receivers to [] in helper utilities.
- Remember strict-mode functions do not coerce null `this` to the global object.
When it happens
Trigger: Calling [].indexOf.call(null, x) or [].indexOf.apply(undefined, args); invoking the polyfilled function detached on a null this in strict mode (the polyfill's 'use strict' means this is not coerced to global).
Common situations: Generic array-method reuse (Array.prototype.slice/indexOf tricks) with a null first argument; legacy code running on old browsers (IE8) where the polyfill is actually active and receives null from a helper.
Related errors
- Failed to construct 'Promise': Please use the 'new'…
- You must pass a resolver function as the first argument to…
- AvroInput.Error.UnexpectedArrayElementTypeAtNonExpansionPoin…
- Cannot convert value to Base.Array.
- polyfill failed because global object is unavailable in…
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/44c31dc5fc7b5206.
Report an issue: GitHub.
Appendix: source
Thrown at plugins/core-ui/src/main/resources/app/pentaho/shim/es5.js:33
/* ES5 polyfills */
/* eslint no-extend-native: 0 */
// Add trim function to support IE8
if(typeof String.prototype.trim !== "function") {
String.prototype.trim = function() {
return this.replace(/^\s+|\s+$/g, "");
};
}
// Add indexOf function to support IE8
if(!Array.prototype.indexOf) {
Array.prototype.indexOf = function(searchElement /*, fromIndex */) {
"use strict";
if(this == null) {
throw new TypeError();
}
var n, k, t = Object(this),
len = t.length >>> 0;
if(len === 0) {
return -1;
}
n = 0;
if(arguments.length > 1) {
n = Number(arguments[1]);
if(n != n) { // shortcut for verifying if it's NaN
n = 0;
} else if(n != 0 && n != Infinity && n != -Infinity) {
n = (n > 0 || -1) * Math.floor(Math.abs(n));
}
}View on GitHub (pinned to f3058517a1)