pentaho/pentaho-kettle · error · ArgumentRequiredError

text

Error message

text

What it means

MessageBundle.format(text, scope) formats an internationalized message string using a scope. The library throws ArgumentRequiredError when text is null or undefined, deliberately, to catch wrong bundle message ids that resolve to no message.

Solutions

  1. Fix the bundle id/key so the lookup returns an actual message string
  2. Guard: if (msg) bundle.format(msg, scope)
  3. Check the message bundle module exists at the configured path

Example fix

// before
var text = bundle.get('missing.key');
return MessageBundle.format(text, [a]);
// after
var text = bundle.get('existing.key');
if (text == null) return '';
return MessageBundle.format(text, [a]);
Defensive patterns

Strategy: try-catch

Validate before calling

if (text == null) { /* skip formatting or use a default */ }

Type guard

function isFormatableText(t) { return typeof t === 'string' && t.length > 0; }

Try / catch

try { return MessageBundle.format(text, scope); } catch (e) { if (/^text$/.test(e.message) || e instanceof ArgumentRequiredError) return ''; throw e; }

Prevention

When it happens

Trigger: Calling MessageBundle.format(null|undefined, scope); a bundle lookup returning null (e.g. wrong bundle or key) and feeding the result into format; i18n!/... AMD loader returning undefined for a missing bundle module.

Common situations: Misspelled message key so the bundle lookup yields undefined; requesting a nonexistent bundle; refactor renaming a message key while old callers remain.

Related errors


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

Appendix: source

Thrown at plugins/core-ui/src/main/resources/app/pentaho/i18n/MessageBundle.js:167

   * @example
   * MessageBundle.format("text");                    //returns "text"
   * MessageBundle.format("text_{0}");                //returns "text_[?]"
   * MessageBundle.format("text_{0}", ["v1"]);        //returns "text_v1"
   * MessageBundle.format("text_{k}", {"k": "v2"});   //returns "text_v2"
   * MessageBundle.format("text_{v3}", function(p) {  //returns "text_v3"
   *    return p;
   * });
   *
   * @alias format
   * @memberOf pentaho.i18n.MessageBundle
   * @param {string} text The text to format.
   * @param {Array|Object|function} [scope] A scope array, object or function.
   *
   * @return {string} The formatted string.
   */
  MessageBundle.format = function(text, scope) {
    // This is to prevent errors in a wrong message bundle id not being caught!
    if(text == null) throw new ArgumentRequiredError("text");
    var scopeFun;
    if(scope == null)
      scopeFun = function(prop) { return null; };
    else if(typeof scope === "function")
      scopeFun = scope;
    else
      scopeFun = function(prop) { return O.getOwn(scope, prop); };

    return String(text).replace(/(^|[^{])\{([^{}]+)\}/g, function($0, before, prop) {
      var value = scopeFun(prop);
      return before + (value == null ? "[?]" : value.toString());
    });
  };

  /**
   * @alias format
   * @memberOf pentaho.i18n.MessageBundle#
   *

View on GitHub (pinned to f3058517a1)