{"record":{"id":"47f2997570a97527","repo":"apache/beam","slug":"no-such-stream-streamname","errorCode":null,"errorMessage":"No such stream: ${streamName}","messagePattern":"No such stream: (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/testing/FakeDatasetService.java","lineNumber":930,"sourceCode":"      }\n\n      @Override\n      public void close() throws Exception {}\n\n      @Override\n      public void pin() {}\n\n      @Override\n      public void unpin() {}\n    };\n  }\n\n  @Override\n  public ApiFuture<FlushRowsResponse> flush(String streamName, long offset) {\n    synchronized (FakeDatasetService.class) {\n      Stream stream = writeStreams.get(streamName);\n      if (stream == null) {\n        throw new RuntimeException(\"No such stream: \" + streamName);\n      }\n      stream.flush(offset);\n    }\n    return ApiFutures.immediateFuture(FlushRowsResponse.newBuilder().build());\n  }\n\n  @Override\n  public ApiFuture<FinalizeWriteStreamResponse> finalizeWriteStream(String streamName) {\n    synchronized (FakeDatasetService.class) {\n      Stream stream = writeStreams.get(streamName);\n      if (stream == null) {\n        throw new RuntimeException(\"No such stream: \" + streamName);\n      }\n      long numRows = stream.finalizeStream();\n      return ApiFutures.immediateFuture(\n          FinalizeWriteStreamResponse.newBuilder().setRowCount(numRows).build());\n    }\n  }","sourceCodeStart":912,"sourceCodeEnd":948,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/testing/FakeDatasetService.java#L912-L948","documentation":"FakeDatasetService is Beam's in-memory fake of the Google Cloud BigQuery Storage Write API used in tests. flush(streamName, offset) looks up the given stream name in the fake's internal writeStreams map; when the name is not present it throws RuntimeException(\"No such stream: ...\"). This means the test harness was asked to flush a stream it never created (via createWriteStream) or has already removed/finalized.","triggerScenarios":"Calling flush(streamName, offset) on the fake with a stream name that was never created with createWriteStream, a misspelled/interleaved stream name, or a stream from a previous test run's state that was not reset.","commonSituations":"Test code wiring a BigQueryIO write with the fake service but using stream names obtained from a different fake instance; reusing a fake across tests without clearing writeStreams; mixing real and fake client references in an integration test.","solutions":["Create the write stream before flushing: call createWriteStream for the stream name passed to flush.","Verify the streamName string matches exactly the one returned by createWriteStream (no truncation or re-formatting).","Ensure the test uses one FakeDatasetService instance consistently; construct a fresh fake (or clear its state) per test to avoid stale/absent streams.","Check that the fake instance registered in the test's client options is the same one the writer is flushing against."],"exampleFix":"// before\nfakeDatasetService.flush(\"unknown-stream\", 0);\n// after\nString streamName = fakeDatasetService.createWriteStream(tableUrn, WriteStreamRequest.newBuilder().setType(Type.BUFFERED).build()).getName();\nfakeDatasetService.append(streamName, rows);\nfakeDatasetService.flush(streamName, 0);","handlingStrategy":"try-catch","validationCode":"boolean exists = fake.getWriteStreams().containsKey(streamName); // or track created names in a Set during the test\nif (!exists) { throw new IllegalStateException(\"flush before createWriteStream: \" + streamName); }","typeGuard":null,"tryCatchPattern":"try {\n  fake.flush(streamName, offset);\n} catch (RuntimeException e) {\n  if (e.getMessage().startsWith(\"No such stream:\")) {\n    throw new AssertionError(\"Stream was not created on this FakeDatasetService: \" + streamName, e);\n  }\n  throw e;\n}","preventionTips":["Always create streams via createWriteStream on the same fake instance and keep the returned names in a test-local collection.","Use a fresh fake per test method to avoid stale state.","Assert stream existence before flush in test helper utilities."],"tags":["java","bigquery","test-harness","stream-not-found"],"backgroundTag":"resource-not-found","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"}