{"record":{"id":"1b98b030c760055d","repo":"pentaho/pentaho-kettle","slug":"error-opening-dbf-metadata","errorCode":null,"errorMessage":"Error opening DBF metadata","messagePattern":"Error opening DBF metadata","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/xbaseinput/XBase.java","lineNumber":79,"sourceCode":"    inputstream = null;\n  }\n\n  public XBase( LogChannelInterface log, InputStream inputStream ) {\n    this.log = log;\n    this.dbfFile = null;\n    this.error = false;\n    this.reader = null;\n    this.inputstream = inputStream;\n  }\n\n  public void open() throws KettleException {\n    try {\n      if ( inputstream == null ) {\n        inputstream = new FileInputStream( dbfFile );\n      }\n      reader = new DBFReader( inputstream );\n    } catch ( DBFException e ) {\n      throw new KettleException( \"Error opening DBF metadata\", e );\n    } catch ( IOException e ) {\n      throw new KettleException( \"Error reading DBF file\", e );\n    }\n  }\n\n  @SuppressWarnings( \"fallthrough\" )\n  public RowMetaInterface getFields() throws KettleException {\n    String debug = \"get fields from XBase file\";\n    RowMetaInterface row = new RowMeta();\n\n    try {\n      // Fetch all field information\n      //\n      debug = \"allocate data types\";\n      datatype = new byte[reader.getFieldCount()];\n\n      for ( int i = 0; i < reader.getFieldCount(); i++ ) {\n        if ( log.isDebug() ) {","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/xbaseinput/XBase.java#L61-L97","documentation":"XBase.open() opens the .dbf file and constructs a DBFReader. A DBFException from the JavaDBF reader (structurally invalid DBF header/records) is wrapped as 'Error opening DBF metadata'. This distinguishes a corrupt/invalid DBF format problem from a plain I/O problem (which produces 'Error reading DBF file').","triggerScenarios":"Calling open() — directly or via getOutputFields(), check(), getFields(), readFile() — when new DBFReader(inputstream) throws DBFException because the stream does not contain a valid DBF file structure.","commonSituations":"Pointing the step at a file with .dbf extension that is actually CSV/text; truncated or corrupted DBF download; DBF saved by a tool using an unsupported dBASE variant; zero-byte file.","solutions":["Verify the file is a genuine DBF: check the first bytes (valid dBASE files start with a version byte, e.g. 0x03/0x30) and open it in a DBF viewer.","Re-export or re-download the DBF file; ensure the transfer was not ASCII-mangled (use binary mode).","Confirm the dbfFile path points to the intended file, not a companion .dbt memo or an unrelated file.","If the file comes from another system, save it with a compatible dBASE III/IV format before use."],"exampleFix":"// before\nString dbfFile = \"/data/export.csv\"; // wrong file supplied\n// after\nString dbfFile = \"/data/export.dbf\"; // actual dBASE file","handlingStrategy":"validation","validationCode":"File f = new File(dbfFile);\nif (!f.isFile() || f.length() < 33) {\n  throw new IllegalArgumentException(\"Not a plausible DBF file: \" + dbfFile);\n}\nint versionByte = new java.io.RandomAccessFile(f, \"r\").read(); // expect 0x03/0x30 etc.\nif (versionByte == 'C' || versionByte == '{') { throw new IllegalArgumentException(\"File is not dBASE format\"); }","typeGuard":null,"tryCatchPattern":"try {\n  xbase.open();\n} catch (KettleException e) {\n  if (e.getMessage().contains(\"Error opening DBF metadata\")) {\n    // file is not valid DBF: re-export or repair before retry\n  }\n}","preventionTips":["Verify file magic bytes before pointing the step at a .dbf path.","Transfer DBF files in binary mode only.","Export from source systems in dBASE III/IV compatible format.","Check file size is nonzero after downloads."],"tags":["dbf","xbase","file-format","kettle"],"backgroundTag":"file-read-failed","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"}