{"record":{"id":"6d0d8eb5e480e762","repo":"pentaho/pentaho-kettle","slug":"error-retrieving-discardfile-string","errorCode":null,"errorMessage":"Error retrieving discardfile string","messagePattern":"Error retrieving discardfile string","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"plugins/oracle-bulk-loader/impl/src/main/java/org/pentaho/di/trans/steps/orabulkloader/OraBulkLoader.java","lineNumber":415,"sourceCode":"\n        sb.append( \" bad=\\'\" );\n        sb.append( getFilename( fileObject ) );\n        sb.append( \"\\'\" );\n      } catch ( KettleFileException ex ) {\n        throw new KettleException( \"Error retrieving badfile string\", ex );\n      }\n    }\n\n    if ( meta.getDiscardFile() != null ) {\n      try {\n        FileObject fileObject =\n          getFileObject( meta.getDiscardFile(), getTransMeta() );\n\n        sb.append( \" discard=\\'\" );\n        sb.append( getFilename( fileObject ) );\n        sb.append( \"\\'\" );\n      } catch ( KettleFileException ex ) {\n        throw new KettleException( \"Error retrieving discardfile string\", ex );\n      }\n    }\n\n    DatabaseMeta dm = meta.getDatabaseMeta();\n    if ( dm != null ) {\n      String user = Const.NVL( dm.getUsername(), \"\" );\n      String pass =\n        Const.NVL( Encr.decryptPasswordOptionallyEncrypted( environmentSubstitute( dm.getPassword() ) ), \"\" );\n      if ( !password ) {\n        pass = \"******\";\n      }\n      String dns = Const.NVL( dm.getDatabaseName(), \"\" );\n      sb.append( \" userid=\" ).append( environmentSubstitute( user ) ).append( \"/\" ).append(\n        environmentSubstitute( pass ) ).append( \"@\" );\n\n      String overrideName = meta.getDbNameOverride();\n      if ( Utils.isEmpty( Const.rtrim( overrideName ) ) ) {\n        sb.append( environmentSubstitute( dns ) );","sourceCodeStart":397,"sourceCodeEnd":433,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/oracle-bulk-loader/impl/src/main/java/org/pentaho/di/trans/steps/orabulkloader/OraBulkLoader.java#L397-L433","documentation":"When a discard file is configured, createCommandLine resolves it via VFS and appends discard='<path>'. A KettleFileException while resolving or reading the filename is wrapped and rethrown as this KettleException.","triggerScenarios":"meta.getDiscardFile() is non-null but getFileObject(meta.getDiscardFile(), transMeta) or getFilename throws KettleFileException during createCommandLine (execute).","commonSituations":"Discard file path has an undefined variable; target directory does not exist; path scheme typo; relative path invalid on the host executing the transformation.","solutions":["Fix the discard file path in the step dialog; ensure the directory exists and is writable.","Define any environment variables used in the path.","Use an absolute path or valid VFS URL.","Clear the discard file field if it is not needed (error only fires when a value is set)."],"exampleFix":"// before\ndiscard file = ${DISCARD_DIR}/load.dsc\n// after\ndiscard file = /tmp/orabulk/load.dsc","handlingStrategy":"validation","validationCode":"// Java: pre-check optional discard file path\nString dsc = meta.getDiscardFile();\nif (dsc != null) {\n  String resolved = transMeta.environmentSubstitute(dsc);\n  File dir = new File(resolved).getAbsoluteFile().getParentFile();\n  if (!dir.isDirectory() || !dir.canWrite()) {\n    throw new IllegalStateException(\"Discard-file directory missing/unwritable: \" + dir);\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  trans.execute(null);\n} catch (KettleException e) {\n  if (String.valueOf(e.getMessage()).contains(\"Error retrieving discardfile\")) {\n    // fix or clear the discard file field\n  }\n}","preventionTips":["Validate all optional file paths (log/bad/discard) together in one pre-flight check.","Use absolute paths per execution host.","Create target directories during deployment."],"tags":["kettle","oracle","discardfile","path-resolution"],"backgroundTag":"file-not-found","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"}