pentaho/pentaho-kettle · error · KettleException

Error retrieving badfile string

Error message

Error retrieving badfile string

What it means

When a bad (rejected-rows) file is configured, createCommandLine resolves it via VFS and appends bad='<path>'. A KettleFileException while resolving or getting the filename is wrapped in this KettleException.

Solutions

  1. Correct the bad file path in the step dialog to an absolute, writable location.
  2. Resolve/define environment variables used in the path.
  3. Create the target directory and grant write permissions to the runtime user.
  4. Clear the bad file field if rejected-row capture is not required.

Example fix

// before
bad file = ${BAD_DIR}/load.bad
// after
bad file = /tmp/orabulk/load.bad
Defensive patterns

Strategy: validation

Validate before calling

// Java: pre-check optional bad file path
String bad = meta.getBadFile();
if (bad != null) {
  String resolved = transMeta.environmentSubstitute(bad);
  File dir = new File(resolved).getAbsoluteFile().getParentFile();
  if (!dir.isDirectory() || !dir.canWrite()) {
    throw new IllegalStateException("Bad-file directory missing/unwritable: " + dir);
  }
}

Try / catch

try {
  trans.execute(null);
} catch (KettleException e) {
  if (String.valueOf(e.getMessage()).contains("Error retrieving badfile")) {
    // fix or clear the bad file field
  }
}

Prevention

When it happens

Trigger: meta.getBadFile() is non-null but getFileObject(meta.getBadFile(), transMeta) or getFilename throws during createCommandLine (execute).

Common situations: Bad file path contains an unresolvable variable; directory missing or read-only; invalid VFS URL; relative path resolved against an unexpected working directory on an agent node.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


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

Appendix: source

Thrown at plugins/oracle-bulk-loader/impl/src/main/java/org/pentaho/di/trans/steps/orabulkloader/OraBulkLoader.java:402

        sb.append( " log=\'" );
        sb.append( getFilename( fileObject ) );
        sb.append( "\'" );
      } catch ( KettleFileException ex ) {
        throw new KettleException( "Error retrieving logfile string", ex );
      }
    }

    if ( meta.getBadFile() != null ) {
      try {
        FileObject fileObject =
          getFileObject( meta.getBadFile(), getTransMeta() );

        sb.append( " bad=\'" );
        sb.append( getFilename( fileObject ) );
        sb.append( "\'" );
      } catch ( KettleFileException ex ) {
        throw new KettleException( "Error retrieving badfile string", ex );
      }
    }

    if ( meta.getDiscardFile() != null ) {
      try {
        FileObject fileObject =
          getFileObject( meta.getDiscardFile(), getTransMeta() );

        sb.append( " discard=\'" );
        sb.append( getFilename( fileObject ) );
        sb.append( "\'" );
      } catch ( KettleFileException ex ) {
        throw new KettleException( "Error retrieving discardfile string", ex );
      }
    }

    DatabaseMeta dm = meta.getDatabaseMeta();
    if ( dm != null ) {

View on GitHub (pinned to f3058517a1)