{"record":{"id":"59993ca77e249262","repo":"pentaho/pentaho-kettle","slug":"please-specify-a-filename-before-saving-messages-store-for","errorCode":null,"errorMessage":"Please specify a filename before saving messages store for package '","messagePattern":"Please specify a filename before saving messages store for package '","errorType":"validation","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"ui/src/main/java/org/pentaho/di/ui/i18n/MessagesStore.java","lineNumber":118,"sourceCode":"      }\n      boolean first = true;\n      for ( KeyOccurrence occ : keyList ) {\n        if ( first ) {\n          first = false;\n        } else {\n          keys += \", \";\n        }\n        keys += occ.getKey() + \"/\" + occ.getFileObject().toString();\n      }\n      keys += \"]\";\n      throw new KettleException( \"Unable to read messages file for locale : '\"\n        + locale + \"' and package '\" + messagesPackage + \"', keys=\" + keys, e );\n    }\n  }\n\n  public void write() throws KettleException {\n    if ( filename == null ) {\n      throw new KettleException( \"Please specify a filename before saving messages store for package '\"\n        + messagesPackage + \"' and locale '\" + locale + \"\" );\n    }\n    write( filename );\n  }\n\n  public void write( String filename ) throws KettleException {\n    try {\n      File file = new File( filename );\n      if ( !file.exists() ) {\n        File parent = file.getParentFile();\n        if ( !parent.exists() ) {\n          parent.mkdirs(); // create the messages/ folder\n        }\n      }\n      Properties properties = new Properties();\n      for ( String key : messagesMap.keySet() ) {\n        properties.put( key, messagesMap.get( key ) );\n      }","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/ui/src/main/java/org/pentaho/di/ui/i18n/MessagesStore.java#L100-L136","documentation":"MessagesStore.write() requires a filename to have been assigned before saving. If the store was created without a file (e.g. built in memory by the Translator) and write() is called without first calling write(String filename) or findFile(), this guard throws. It is an explicit pre-condition check to prevent silently discarding translations.","triggerScenarios":"Calling the no-argument write() on a MessagesStore whose filename field is still null — i.e. a store constructed manually or loaded without resolving a file via getLoadFilename/findFile.","commonSituations":"Programmatic use of MessagesStore (scripts/plugins around the Translator) that builds a store and saves it before a filename was ever set; Translator tool edge cases where no file could be located for the locale.","solutions":["Call write( String filename ) with an explicit target path instead of the no-arg write().","Call findFile()/getLoadFilename() first so the store gets a resolved filename, then save.","In UI code, ensure the save action only runs after 'Save As' assigned a filename."],"exampleFix":"// before\nstore.write(); // filename == null -> KettleException\n\n// after\nif ( store.getFilename() == null ) {\n  store.write( \"/path/to/messages/messages_en_US.properties\" );\n} else {\n  store.write();\n}","handlingStrategy":"validation","validationCode":"if ( store.getFilename() == null ) {\n  throw new IllegalStateException( \"Assign a filename (write(path)) before saving\" );\n}\nstore.write();","typeGuard":null,"tryCatchPattern":"try {\n  store.write();\n} catch ( KettleException e ) {\n  if ( e.getMessage().startsWith( \"Please specify a filename\" ) ) {\n    store.write( promptUserForSaveAsPath() );\n  } else { throw e; }\n}","preventionTips":["Always resolve a filename via findFile() or Save As before persisting a MessagesStore","Track store state (dirty + filename null) in UI to enable Save vs Save As correctly"],"tags":["i18n","state-error","precondition","save"],"backgroundTag":"missing-required-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"}