{"record":{"id":"5e43f3ecee775219","repo":"pentaho/pentaho-kettle","slug":"format-problem-with-key-key-locale-locale-package","errorCode":null,"errorMessage":"Format problem with key=[${key}], locale=[${locale}], package=${packageName} : ${e}","messagePattern":"Format problem with key=\\[(.+?)\\], locale=\\[(.+?)\\], package=(.+?) : (.+?)","errorType":"exception","errorClass":"MissingResourceException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/i18n/GlobalMessageUtil.java","lineNumber":273,"sourceCode":"    return calculateString( packageName, locale, key, parameters, resourceClass, bundleName, true );\n  }\n\n  @VisibleForTesting\n  static String calculateString( final String packageName, final Locale locale, final String key,\n                                 final Object[] parameters, final Class<?> resourceClass, final String bundleName,\n                                 final boolean fallbackOnRoot ) throws MissingResourceException {\n    try {\n      ResourceBundle bundle = getBundle( locale, packageName + \".\" + bundleName, resourceClass, fallbackOnRoot );\n      String unformattedString = bundle.getString( key );\n      String string = MessageFormat.format( unformattedString, parameters );\n      return string;\n    } catch ( IllegalArgumentException e ) {\n      final StringBuilder msg = new StringBuilder();\n      msg.append( \"Format problem with key=[\" ).append( key ).append( \"], locale=[\" ).append( locale ).append(\n        \"], package=\" ).append( packageName ).append( \" : \" ).append( e.toString() );\n      log.error( msg.toString() );\n      log.error( Const.getStackTracker( e ) );\n      throw new MissingResourceException( msg.toString(), packageName, key );\n    }\n  }\n\n  /**\n   * Retrieve a resource bundle of the default or fail-over locales.\n   *\n   * @param packagePath   The package to search in\n   * @param resourceClass the class to use to resolve the bundle\n   * @return The resource bundle\n   * @throws MissingResourceException in case both resource bundles couldn't be found.\n   */\n  public static ResourceBundle getBundle( final String packagePath, final Class<?> resourceClass )\n    throws MissingResourceException {\n    final Set<Locale> activeLocales = getActiveLocales();\n    for ( final Locale locale : activeLocales ) {\n      try {\n        return getBundle( locale, packagePath, resourceClass );\n      } catch ( MissingResourceException e ) {","sourceCodeStart":255,"sourceCodeEnd":291,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/i18n/GlobalMessageUtil.java#L255-L291","documentation":"calculateString formats a message-bundle entry with MessageFormat; if the pattern is malformed or arguments don't match placeholders, MessageFormat throws IllegalArgumentException, which is converted into a MissingResourceException carrying 'Format problem with key=[key], locale=[locale], package=packageName'. The bundle exists but its template cannot be formatted with the supplied arguments.","triggerScenarios":"BaseMessages.getString(PKG, key, args...) where the properties entry has a malformed {0} pattern (unclosed brace, bad format type) or the argument types mismatch (e.g. passing a String where {0,number} expects a Number) for the resolved locale.","commonSituations":"Custom-translated properties files with broken MessageFormat syntax, passing wrong number/type of substitution arguments, locale-specific pattern differences, single quotes in messages not escaped ('' needed) breaking placeholders.","solutions":["Inspect the properties file entry for the key in the reported locale/package; fix the MessageFormat pattern (escape quotes as '', verify {0},{1} indices).","Match the argument count/types to the placeholders in the message template.","Test the key with the default English bundle to isolate locale-specific breakage.","Catch MissingResourceException around getString calls for user-supplied/custom bundles."],"exampleFix":"// broken properties entry\nMyApp.Error=Can't open file {0} for {1,number}\n// fixed\nMyApp.Error=Can''t open file {0} for record {1}\n// and call: BaseMessages.getString(PKG, \"MyApp.Error\", fileName, recordId);","handlingStrategy":"try-catch","validationCode":"try {\n  new java.text.MessageFormat(bundle.getString(key), locale).format(args);\n} catch (IllegalArgumentException e) { /* bad pattern or args */ }","typeGuard":null,"tryCatchPattern":"try {\n  msg = BaseMessages.getString(PKG, key, args);\n} catch (MissingResourceException e) {\n  log.error(\"Bad message pattern for \" + key + \": \" + e.getMessage());\n  msg = key; // safe fallback\n}","preventionTips":["Escape single quotes as '' in MessageFormat templates","Keep placeholder indices/types in sync with call-site arguments","Lint custom translations with MessageFormat.format in unit tests"],"tags":["i18n","message-format","resources"],"backgroundTag":"invalid-argument-format","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"}