pentaho/pentaho-kettle · error · Error

Cannot convert value to Base.Array.

Error message

Cannot convert value to Base.Array.

What it means

Base.Array.to(value, ...) is the conversion entry point for the Base.Array type. It accepts null/undefined (yielding an empty array), passes through existing instances of the class, and accepts native JS Arrays (adapting them via applyClass). Any other value — a plain object, string, number, Map, etc. — cannot be interpreted as an array, so the conversion throws 'Cannot convert value to Base.Array.'

Solutions

  1. Wrap scalars in an array before converting: Base.Array.to([value]).
  2. Convert iterables with Array.from(value) first, then call .to().
  3. Check the caller that produced the value — a JSON payload or config probably lost its array shape.
  4. If a single-element default is intended, guard: var arr = value == null ? [] : (Array.isArray(value) ? value : [value]).

Example fix

// before
Base.Array.to(value); // value = {items: [1,2]} -> throws
// after
Base.Array.to(value == null ? [] : (Array.isArray(value) ? value : [value]));
Defensive patterns

Strategy: type-guard

Validate before calling

function asArray(value) {
  if (value == null) return [];
  if (Array.isArray(value)) return value;
  if (typeof value[Symbol.iterator] === "function") return Array.from(value);
  return [value];
}
Base.Array.to(asArray(value));

Type guard

function isConvertableToBaseArray(v) {
  return v == null || Array.isArray(v) || v instanceof Base.Array;
}

Try / catch

try {
  return Base.Array.to(value);
} catch (e) {
  if (String(e.message).indexOf("Cannot convert value to Base.Array") !== -1) {
    return Base.Array.to(value == null ? [] : [value]);
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling Base.Array.to(value) or a subclass's .to() where value is non-null, not an instance of the Base.Array class, and not an instanceof Array — e.g. to({a:1}), to("abc"), to(42), or to(new Map()).

Common situations: API/config layers handing a single element (not wrapped in an array) where an array was expected; deserialized JSON where an array field became an object; passing an iterable (Set/Map/arguments) that is not a real Array; refactors changing a field from array to scalar.

Understand the failure class

Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.

Related errors


AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13). Data as JSON: /api/errors/24cb8fb1c24c1c1f. Report an issue: GitHub.

Appendix: source

Thrown at plugins/core-ui/src/main/resources/app/pentaho/lang/Base.js:716

   * @alias pentaho.lang.Base.Array.to
   *
   * @param {pentaho.lang.Base.Array|Array} value The value to be converted.
   * @param {...*} other Remaining arguments passed alongside `value` to the class constructor.
   *
   * @return {pentaho.lang.Base.Array} The converted value.
   *
   * @throws {Error} When `value` cannot be converted.
   */
  function class_array_to(value) {
    /* jshint validthis:true*/

    // First, convert to an array.
    if(value == null)
      value = [];
    else if(value instanceof this)
      return value;
    else if(!(value instanceof Array))
      throw new Error("Cannot convert value to Base.Array.");

    return O.applyClass(value, this, A_slice.call(arguments, 1));
  }

  /**
   * Adds additional members to, or overrides existing ones of, this class.
   *
   * This method does _not_ create a new class.
   *
   * This method supports two signatures:
   *
   * 1. mix(Class: function[, keyArgs: Object]) -
   *     mixes-in the given class, both its instance and class sides.
   *
   * 2. mix(instSpec: Object[, classSpec: Object[, keyArgs: Object]]) -
   *     mixes-in the given instance and class side specifications.
   *
   * @alias mix

View on GitHub (pinned to f3058517a1)