{"record":{"id":"8b1579cb4dfd9a6c","repo":"pentaho/pentaho-kettle","slug":"text","errorCode":null,"errorMessage":"text","messagePattern":"text","errorType":"validation","errorClass":"ArgumentRequiredError","httpStatus":null,"severity":"error","filePath":"plugins/core-ui/src/main/resources/app/pentaho/i18n/MessageBundle.js","lineNumber":167,"sourceCode":"   * @example\n   * MessageBundle.format(\"text\");                    //returns \"text\"\n   * MessageBundle.format(\"text_{0}\");                //returns \"text_[?]\"\n   * MessageBundle.format(\"text_{0}\", [\"v1\"]);        //returns \"text_v1\"\n   * MessageBundle.format(\"text_{k}\", {\"k\": \"v2\"});   //returns \"text_v2\"\n   * MessageBundle.format(\"text_{v3}\", function(p) {  //returns \"text_v3\"\n   *    return p;\n   * });\n   *\n   * @alias format\n   * @memberOf pentaho.i18n.MessageBundle\n   * @param {string} text The text to format.\n   * @param {Array|Object|function} [scope] A scope array, object or function.\n   *\n   * @return {string} The formatted string.\n   */\n  MessageBundle.format = function(text, scope) {\n    // This is to prevent errors in a wrong message bundle id not being caught!\n    if(text == null) throw new ArgumentRequiredError(\"text\");\n    var scopeFun;\n    if(scope == null)\n      scopeFun = function(prop) { return null; };\n    else if(typeof scope === \"function\")\n      scopeFun = scope;\n    else\n      scopeFun = function(prop) { return O.getOwn(scope, prop); };\n\n    return String(text).replace(/(^|[^{])\\{([^{}]+)\\}/g, function($0, before, prop) {\n      var value = scopeFun(prop);\n      return before + (value == null ? \"[?]\" : value.toString());\n    });\n  };\n\n  /**\n   * @alias format\n   * @memberOf pentaho.i18n.MessageBundle#\n   *","sourceCodeStart":149,"sourceCodeEnd":185,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/core-ui/src/main/resources/app/pentaho/i18n/MessageBundle.js#L149-L185","documentation":"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.","triggerScenarios":"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.","commonSituations":"Misspelled message key so the bundle lookup yields undefined; requesting a nonexistent bundle; refactor renaming a message key while old callers remain.","solutions":["Fix the bundle id/key so the lookup returns an actual message string","Guard: if (msg) bundle.format(msg, scope)","Check the message bundle module exists at the configured path"],"exampleFix":"// before\nvar text = bundle.get('missing.key');\nreturn MessageBundle.format(text, [a]);\n// after\nvar text = bundle.get('existing.key');\nif (text == null) return '';\nreturn MessageBundle.format(text, [a]);","handlingStrategy":"try-catch","validationCode":"if (text == null) { /* skip formatting or use a default */ }","typeGuard":"function isFormatableText(t) { return typeof t === 'string' && t.length > 0; }","tryCatchPattern":"try { return MessageBundle.format(text, scope); } catch (e) { if (/^text$/.test(e.message) || e instanceof ArgumentRequiredError) return ''; throw e; }","preventionTips":["Verify message keys exist in the bundle before formatting","Never feed the raw result of a lookup that may return null into format","Write a test that renders every key used in code against the actual bundles"],"tags":["argument-validation","i18n","null-value"],"backgroundTag":"null-argument","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"}