{"record":{"id":"24cb8fb1c24c1c1f","repo":"pentaho/pentaho-kettle","slug":"cannot-convert-value-to-base-array","errorCode":null,"errorMessage":"Cannot convert value to Base.Array.","messagePattern":"Cannot convert value to Base\\.Array\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"plugins/core-ui/src/main/resources/app/pentaho/lang/Base.js","lineNumber":716,"sourceCode":"   * @alias pentaho.lang.Base.Array.to\n   *\n   * @param {pentaho.lang.Base.Array|Array} value The value to be converted.\n   * @param {...*} other Remaining arguments passed alongside `value` to the class constructor.\n   *\n   * @return {pentaho.lang.Base.Array} The converted value.\n   *\n   * @throws {Error} When `value` cannot be converted.\n   */\n  function class_array_to(value) {\n    /* jshint validthis:true*/\n\n    // First, convert to an array.\n    if(value == null)\n      value = [];\n    else if(value instanceof this)\n      return value;\n    else if(!(value instanceof Array))\n      throw new Error(\"Cannot convert value to Base.Array.\");\n\n    return O.applyClass(value, this, A_slice.call(arguments, 1));\n  }\n\n  /**\n   * Adds additional members to, or overrides existing ones of, this class.\n   *\n   * This method does _not_ create a new class.\n   *\n   * This method supports two signatures:\n   *\n   * 1. mix(Class: function[, keyArgs: Object]) -\n   *     mixes-in the given class, both its instance and class sides.\n   *\n   * 2. mix(instSpec: Object[, classSpec: Object[, keyArgs: Object]]) -\n   *     mixes-in the given instance and class side specifications.\n   *\n   * @alias mix","sourceCodeStart":698,"sourceCodeEnd":734,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/core-ui/src/main/resources/app/pentaho/lang/Base.js#L698-L734","documentation":"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.'","triggerScenarios":"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()).","commonSituations":"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.","solutions":["Wrap scalars in an array before converting: Base.Array.to([value]).","Convert iterables with Array.from(value) first, then call .to().","Check the caller that produced the value — a JSON payload or config probably lost its array shape.","If a single-element default is intended, guard: var arr = value == null ? [] : (Array.isArray(value) ? value : [value])."],"exampleFix":"// before\nBase.Array.to(value); // value = {items: [1,2]} -> throws\n// after\nBase.Array.to(value == null ? [] : (Array.isArray(value) ? value : [value]));","handlingStrategy":"type-guard","validationCode":"function asArray(value) {\n  if (value == null) return [];\n  if (Array.isArray(value)) return value;\n  if (typeof value[Symbol.iterator] === \"function\") return Array.from(value);\n  return [value];\n}\nBase.Array.to(asArray(value));","typeGuard":"function isConvertableToBaseArray(v) {\n  return v == null || Array.isArray(v) || v instanceof Base.Array;\n}","tryCatchPattern":"try {\n  return Base.Array.to(value);\n} catch (e) {\n  if (String(e.message).indexOf(\"Cannot convert value to Base.Array\") !== -1) {\n    return Base.Array.to(value == null ? [] : [value]);\n  }\n  throw e;\n}","preventionTips":["Wrap scalar API results in arrays at the boundary before calling .to().","Use Array.from for Set/Map/iterables instead of passing them directly.","Check serialized payloads keep array fields as arrays (schema/serialization tests).","Remember only real Arrays pass — plain objects and arguments objects do not."],"tags":["type-conversion","type-mismatch","array"],"backgroundTag":"type-mismatch","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"}