{"record":{"id":"588ec784c1b39384","repo":"apache/beam","slug":"bounded-source-is-not-bigquerystoragestreamsource-unable-to","errorCode":null,"errorMessage":"Bounded Source is not BigQueryStorageStreamSource, unable to read","messagePattern":"Bounded Source is not BigQueryStorageStreamSource, unable to read","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryIO.java","lineNumber":1985,"sourceCode":"          BadRecordRouter badRecordRouter) {\n        this.rowTag = rowTag;\n        this.parseFn = parseFn;\n        this.badRecordRouter = badRecordRouter;\n      }\n\n      @ProcessElement\n      public void processElement(\n          @Element BoundedSource<T> boundedSource,\n          MultiOutputReceiver outputReceiver,\n          PipelineOptions options)\n          throws Exception {\n        ErrorHandlingParseFn<T> errorHandlingParseFn = new ErrorHandlingParseFn<T>(parseFn);\n        BoundedSource<T> sourceWithErrorHandlingParseFn;\n        if (boundedSource instanceof BigQueryStorageStreamSource) {\n          sourceWithErrorHandlingParseFn =\n              ((BigQueryStorageStreamSource<T>) boundedSource).fromExisting(errorHandlingParseFn);\n        } else {\n          throw new RuntimeException(\n              \"Bounded Source is not BigQueryStorageStreamSource, unable to read\");\n        }\n        readSource(\n            options,\n            rowTag,\n            outputReceiver,\n            sourceWithErrorHandlingParseFn,\n            errorHandlingParseFn,\n            badRecordRouter);\n      }\n    }\n\n    private PCollectionTuple createTupleForDirectRead(\n        PCollection<String> jobIdTokenCollection,\n        Coder<T> outputCoder,\n        TupleTag<ReadStream> readStreamsTag,\n        TupleTag<ReadSession> readSessionTag,\n        TupleTag<String> tableSchemaTag) {","sourceCodeStart":1967,"sourceCodeEnd":2003,"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#L1967-L2003","documentation":"Thrown in the Storage API streaming read path when the provided BoundedSource is not a BigQueryStorageStreamSource, so Beam cannot create a copy with the error-handling parse function. This is an internal invariant: the source passed to the reader was of the wrong type.","triggerScenarios":"BigQueryIO Storage API read path receives a BoundedSource from an unexpected origin (e.g. after a runner-specific source rewrite, test injection, or method mismatch) and the instanceof check fails.","commonSituations":"Custom runners or test harnesses substituting sources; mixing Storage API read settings with sources produced by the EXPORT method; Beam version upgrade changing source types.","solutions":["Ensure the read uses TypedRead.Method.DIRECT_READ/STORAGE_API so a BigQueryStorageStreamSource is produced","Use fromExisting()/from a source created by the same BigQueryIO version","Update Beam to a consistent version across pipeline construction and runner classpath"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":"boolean isStorageStreamSource(BoundedSource<?> s) {\n  return s instanceof BigQueryStorageStreamSource;\n}","tryCatchPattern":"if (!(boundedSource instanceof BigQueryStorageStreamSource)) {\n  throw new IllegalStateException(\n      \"Expected BigQueryStorageStreamSource but got \" + boundedSource.getClass().getName());\n}","preventionTips":["Keep Beam versions consistent between pipeline code and runner classpath","Only feed sources produced by the Storage API read path into stream-source consumers","Pin the Beam version when using custom runners"],"tags":["bigquery","storage-api","type-mismatch","java"],"backgroundTag":"internal-invariant-violation","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}