pentaho/pentaho-kettle · error · pentaho.lang.ArgumentRequiredError

Argument is required.

Error message

Argument ${pscope.p} is required.

What it means

pentaho.util.arg.required(o, p, pscope) extracts property p from object o and throws ArgumentRequiredError with the (optionally scoped) property name when o is falsy or o[p] is null/undefined. The message interpolates the caller-supplied scope prefix, e.g. 'Argument sortSpec.field is required.'

Solutions

  1. Provide the required property before invoking the API: options.prop = value.
  2. Validate the options object shape with arg.required (or your own checks) at entry points to fail early.
  3. Check upstream data sources (config, server payload) that leave the field unset and add defaults.

Example fix

// before
util.Arg.required(options, 'field', 'sortSpec'); // throws
// after
options.sortSpec = options.sortSpec || {};
options.sortSpec.field = options.sortSpec.field || 'name';
util.Arg.required(options, 'field', 'sortSpec');
Defensive patterns

Strategy: validation

Validate before calling

if (o == null || o[p] == null) { throw new Error('Missing ' + p + ' in options'); }
var v = arg.required(o, p, pscope);

Type guard

function hasField(o, p) { return o != null && o[p] != null; }

Try / catch

try { v = arg.required(o, p, pscope); } catch (e) { if (/is required/.test(e.message)) { v = defaultValue; } else throw e; }

Prevention

When it happens

Trigger: Calling arg.required(obj, 'prop') where obj is null/undefined, or obj.prop is null/undefined; missing nested fields flagged with a pscope prefix.

Common situations: API options objects missing required fields (e.g. compound filters, sort specs); config objects loaded with omitted sections; callers passing optional structs that happen to be null.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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

Appendix: source

Thrown at plugins/core-ui/src/main/resources/app/pentaho/util/arg.js:79

    /**
     * Gets the value of an required property of an object.
     * The property is considered specified when its value is not a {@link Nully} value.
     *
     * @param {?object} o The object from which to get a property.
     * @param {string} p The name of the property.
     * @param {?string} pscope The name of the argument where the `o` is received in the caller.
     *
     * @return {*} The found required property value.
     * @throws {Error} Argument required. The `o` must contain the `p`.
     */
    required: function(o, p, pscope) {
      var v;
      if(o && (v = o[p]) != null) {
        return v;
      }

      throw new ArgumentRequiredError((pscope ? (pscope + ".") : "") + p);
    },

    /**
     * Slices the provided array.
     *
     * @param {object} args Array of anything.
     * @param {number} [start=0] The index of the `args` array to begin the slice.
     * @param {number} [end] The index of the `args` array to end the slice at.
     *
     * @return {Array} Array containing the elements from the `args` array between the `start` and the `end`.
     */
    slice: function(args, start, end) {
      if(!args) {
        throw new ArgumentRequiredError("args");
      }

      /* eslint default-case: 0 */
      switch(arguments.length) {

View on GitHub (pinned to f3058517a1)