{"record":{"id":"cf3ed8f7ab0769ee","repo":"pentaho/pentaho-kettle","slug":"output-filename-not-set","errorCode":null,"errorMessage":"Output filename not set!","messagePattern":"Output filename not set!","errorType":"exception","errorClass":"KettleFileException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/textfileoutput/TextFileOutput.java","lineNumber":262,"sourceCode":"      if ( data.writer != null ) {\n        filename = data.getFileStreamsCollection().getLastFileName( );\n      } else {\n        filename = meta.getFileName();\n        if ( filename == null ) {\n          throw new KettleFileException( BaseMessages.getString( PKG, \"TextFileOutput.Exception.FileNameNotSet\" ) );\n        }\n        filename = buildFilename( environmentSubstitute( filename ), true );\n      }\n    } else {\n      data.fileNameFieldIndex = getInputRowMeta().indexOfValue( meta.getFileNameField() );\n      if ( data.fileNameFieldIndex < 0 ) {\n        throw new KettleStepException( BaseMessages.getString( PKG, \"TextFileOutput.Exception.FileNameFieldNotFound\", meta.getFileNameField() ) );\n      }\n      data.fileNameMeta = getInputRowMeta().getValueMeta( data.fileNameFieldIndex );\n      data.fileName = data.fileNameMeta.getString( row[data.fileNameFieldIndex] );\n\n      if ( data.fileName == null ) {\n        throw new KettleFileException( BaseMessages.getString( PKG, \"TextFileOutput.Exception.FileNameNotSet\" ) );\n      }\n\n      filename = buildFilename( environmentSubstitute( data.fileName ), true );\n    }\n    return filename;\n  }\n\n  public int getFlushInterval(  )  {\n    String flushIntervalStr = getTransMeta().getVariable( \"KETTLE_FILE_OUTPUT_MAX_STREAM_LIFE\" );\n    int flushInterval = 0;\n    if ( flushIntervalStr != null ) {\n      try {\n        flushInterval = Integer.parseInt( flushIntervalStr );\n      } catch ( Exception ex ) {\n        // Do nothing\n      }\n    }\n    return flushInterval;","sourceCodeStart":244,"sourceCodeEnd":280,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/textfileoutput/TextFileOutput.java#L244-L280","documentation":"When the filename comes from a field, the field's string value for the current row is used as the output file name. If that value is null the step has no file to open, so it throws KettleFileException (message 'Output filename not set!').","triggerScenarios":"FileName field enabled and the field's value is null for the row being written (data.fileName == null in getOutputFileName).","commonSituations":"Input rows with missing/empty filename column; a lookup failed to fill the field; null handling not configured upstream.","solutions":["Fix upstream data so the filename field is never null (e.g. coalesce/default value via 'Value Mapper' or 'If field value is null')","Disable 'File name in field?' and specify a static filename with variables if the name is constant","Filter out rows with null filename before the step"],"exampleFix":"// before: rows may carry null filename\n// after: add 'If field value is null' step setting null -> '/tmp/default.csv', or:\nfilename = Utils.isEmpty( data.fileName ) ? \"/tmp/default.csv\" : buildFilename( environmentSubstitute( data.fileName ), true );","handlingStrategy":"validation","validationCode":"Object v = row[ rowIndex ];\nif ( v == null ) throw new KettleException( \"Filename field is null for this row\" );","typeGuard":"boolean hasFileName( RowMetaInterface m, Object[] row, int idx ) { return idx >= 0 && row[idx] != null && m.getValueMeta( idx ).getString( row[idx] ) != null; }","tryCatchPattern":"try { filename = getOutputFileName( row ); } catch ( KettleFileException e ) { logError( \"Row has null filename: \" + row ); rejectRow( row ); }","preventionTips":["Configure null handling ('If field value is null') upstream","Filter null-filename rows before the step","Use a static filename when the name does not vary per row"],"tags":["kettle","pentaho","textfileoutput","null-value"],"backgroundTag":"empty-required-field","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"}