{"record":{"id":"8e24dcac65e752e9","repo":"pentaho/pentaho-kettle","slug":"jsoninputexception-ke","errorCode":null,"errorMessage":"JsonInputException(ke)","messagePattern":"JsonInputException\\(ke\\)","errorType":"exception","errorClass":"JsonInputException","httpStatus":null,"severity":"error","filePath":"plugins/json/core/src/main/java/org/pentaho/di/trans/steps/jsoninput/JsonInput.java","lineNumber":256,"sourceCode":"\n  @Override\n  protected void fillFileAdditionalFields( JsonInputData data, FileObject file ) throws FileSystemException {\n    super.fillFileAdditionalFields( data, file );\n    data.filename = KettleVFS.getFilename( file );\n    data.filenr++;\n    if ( log.isDetailed() ) {\n      logDetailed( BaseMessages.getString( PKG, \"JsonInput.Log.OpeningFile\", file.toString() ) );\n    }\n    addFileToResultFilesname( file );\n  }\n\n  private void parseNextInputToRowSet( InputStream input ) throws KettleException {\n    try {\n      data.readerRowSet = data.reader.parse( input );\n      input.close();\n    } catch ( KettleException ke ) {\n      logInputError( ke );\n      throw new JsonInputException( ke );\n    } catch ( Exception e ) {\n      logInputError( e );\n      throw new JsonInputException( e );\n    }\n  }\n\n  private void logInputError( KettleException e ) {\n    logError( e.getLocalizedMessage(), e );\n    inputError( e.getLocalizedMessage() );\n  }\n\n  private void logInputError( Exception e ) {\n    String errMsg = ( !meta.isInFields() || meta.getIsAFile() )\n      ? BaseMessages.getString( PKG, \"JsonReader.Error.ParsingFile\", data.filename )\n      : BaseMessages.getString( PKG, \"JsonReader.Error.ParsingString\", data.readrow[ data.indexSourceField ] );\n    logError( errMsg, e );\n    inputError( errMsg );\n  }","sourceCodeStart":238,"sourceCodeEnd":274,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/json/core/src/main/java/org/pentaho/di/trans/steps/jsoninput/JsonInput.java#L238-L274","documentation":"JsonInputException wrapping a KettleException raised while JsonInput.parseNextInputToRowSet() hands the input stream to data.reader.parse(input). The JSON reader (e.g. FastJsonReader via Json parser) failed to parse or process the stream, so the step aborts the transform after logging the underlying error.","triggerScenarios":"getOneOutputRow -> parseNextInputToRowSet: data.reader.parse(input) throws KettleException. Concretely: malformed JSON in a file/URL, unreadable or closed stream, or a nested KettleException from readInput (e.g. parse context null).","commonSituations":"Pointing the step at a truncated or non-JSON file; a URL field returning an HTML error page instead of JSON; encoding mismatch (file not in expected JSON charset); source file removed or locked between file-listing and read.","solutions":["Open the source file/URL and validate it parses as JSON (e.g. with jq or a JSON linter); fix the malformed input.","Check the step log line written by logInputError for the root cause (parse error offset, IO error) and fix accordingly.","If the source is a URL, verify it returns 200 with content-type application/json and is reachable from the Pentaho server host.","Verify the encoding setting in the step matches the file's actual charset.","If transient I/O, re-run; otherwise fix permissions on the source file."],"exampleFix":"// before: reading a file that is not valid JSON\n// after: pre-validate outside the transformation\nString raw = new String(Files.readAllBytes(Paths.get(path)), StandardCharsets.UTF_8);\nnew JSONParser().parse(raw); // throws early with a clear position if invalid","handlingStrategy":"validation","validationCode":"// validate JSON before running the transformation\nbyte[] raw = Files.readAllBytes(Paths.get(path));\nif (raw.length == 0) throw new IllegalStateException(\"Empty JSON file: \" + path);\nnew JSONParser().parse(new String(raw, StandardCharsets.UTF_8));","typeGuard":null,"tryCatchPattern":"try { runTransformation(); }\ncatch (KettleException e) {\n  if (e.getCause() instanceof JsonInputException) { logParseFailure(e); moveToErrorFolder(file); }\n  else throw e;\n}","preventionTips":["Lint source JSON files before ingestion (jq/JSON linter in a prior job step).","Verify URL sources return application/json with a non-error status.","Match the step's encoding setting to the actual file charset.","Use a 'Get File Names' + filter step to skip empty or unreadable files."],"tags":["json","parse-error","etl","kettle"],"backgroundTag":"json-parse-error","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"}