{"record":{"id":"0e335451245f1dbe","repo":"apache/beam","slug":"reader-returned-null-element","errorCode":null,"errorMessage":"Reader returned null element","messagePattern":"Reader returned null element","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryIO.java","lineNumber":2167,"sourceCode":"    public static <T> void readSource(\n        PipelineOptions options,\n        TupleTag<T> rowTag,\n        MultiOutputReceiver outputReceiver,\n        BoundedSource<T> streamSource,\n        ErrorHandlingParseFn<T> errorHandlingParseFn,\n        BadRecordRouter badRecordRouter)\n        throws Exception {\n      // Read all the data from the stream. In the event that this work\n      // item fails and is rescheduled, the same rows will be returned in\n      // the same order.\n      BoundedSource.BoundedReader<T> reader = streamSource.createReader(options);\n\n      @Nullable T current = null;\n      try {\n        if (reader.start()) {\n          current = reader.getCurrent();\n          if (current == null) {\n            throw new IllegalStateException(\"Reader returned null element\");\n          }\n        } else {\n          return;\n        }\n      } catch (ParseException e) {\n        GenericRecord record = errorHandlingParseFn.getSchemaAndRecord().getRecord();\n        badRecordRouter.route(\n            outputReceiver,\n            record,\n            AvroCoder.of(record.getSchema()),\n            (Exception) e.getCause(),\n            \"Unable to parse record reading from BigQuery\");\n      }\n      if (current != null) {\n        outputReceiver.get(rowTag).output(current);\n      }\n\n      while (true) {","sourceCodeStart":2149,"sourceCodeEnd":2185,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryIO.java#L2149-L2185","documentation":"Thrown when a BigQuery source reader reports start()==true (indicating an element is available) but getCurrent() returns null. This violates the BoundedSource contract and is surfaced as IllegalStateException.","triggerScenarios":"During Storage API / Avro record iteration, reader.start() succeeds but the underlying record/element is null — usually an internal reader bug or malformed source data handling.","commonSituations":"Rare; seen with corrupted Avro blocks, runner/source incompatibilities, or Beam bugs in specific versions.","solutions":["Retry the pipeline (often transient per-worker)","Check for known Beam issues and upgrade to a newer Beam version","Verify the source data/schema integrity in BigQuery"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"if (reader.start()) {\n  T current = reader.getCurrent();\n  if (current == null) {\n    // treat as transient worker failure; runner will retry the work item\n    throw new IllegalStateException(\"Reader returned null element\");\n  }\n}","preventionTips":["Upgrade Beam — null-element reader bugs are typically fixed upstream","Watch for corrupt temp files in GCS and clean the temp location","Retry failed work items rather than skipping data"],"tags":["bigquery","reader","null","java"],"backgroundTag":"unexpected-response-shape","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}