{"record":{"id":"21b44f25682cc78b","repo":"apache/beam","slug":"not-found","errorCode":"NOT_FOUND","errorMessage":"NOT_FOUND","messagePattern":"NOT_FOUND","errorType":"error_code","errorClass":"ApiException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/testing/FakeDatasetService.java","lineNumber":752,"sourceCode":"  public WriteStream createWriteStream(String tableUrn, WriteStream.Type type)\n      throws InterruptedException {\n    try {\n      TableReference tableReference =\n          BigQueryHelpers.parseTableUrn(BigQueryHelpers.stripPartitionDecorator(tableUrn));\n      synchronized (FakeDatasetService.class) {\n        TableContainer tableContainer =\n            getTableContainer(\n                tableReference.getProjectId(),\n                tableReference.getDatasetId(),\n                tableReference.getTableId());\n        String streamName = UUID.randomUUID().toString();\n        Stream stream = new Stream(streamName, tableContainer, type);\n        writeStreams.put(streamName, stream);\n        return stream.toWriteStream();\n      }\n    } catch (IOException e) {\n      // TODO(relax): Return the exact error that BigQuery returns.\n      throw new ApiException(e, GrpcStatusCode.of(Status.Code.NOT_FOUND), false);\n    }\n  }\n\n  @Override\n  @Nullable\n  public com.google.cloud.bigquery.storage.v1.TableSchema getWriteStreamSchema(String streamName) {\n    synchronized (FakeDatasetService.class) {\n      @Nullable Stream stream = writeStreams.get(streamName);\n      if (stream != null) {\n        return stream.toWriteStream().getTableSchema();\n      }\n    }\n    // TODO(relax): Return the exact error that BigQuery returns.\n    throw new ApiException(null, GrpcStatusCode.of(Status.Code.NOT_FOUND), false);\n  }\n\n  @Override\n  public StreamAppendClient getStreamAppendClient(","sourceCodeStart":734,"sourceCodeEnd":770,"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#L734-L770","documentation":"The storage-write create/lookup path in FakeDatasetService wraps any IOException in a gRPC ApiException with status NOT_FOUND, because the fake does not reproduce BigQuery's exact error codes (see TODO(relax) comment). Any failure to resolve the stream/table surfaces as NOT_FOUND.","triggerScenarios":"BatchCreateWriteStream / stream creation when the referenced table or dataset does not exist in the fake, or an internal IOException occurs while setting up the write stream.","commonSituations":"Writing to a stream for a table that was never created in the fake service; typos in dataset/table ids in test setup; a fake-side IO failure being masked as NOT_FOUND.","solutions":["Verify the table (and dataset) exist in the fake via createTable/createDataset before creating write streams","Check the stream name/format passed to the storage API","Inspect the wrapped cause (e.getCause()) to see the real IOException since the status is approximated"],"exampleFix":"// before\nstream = client.createWriteStream(\"projects/p/datasets/d/tables/missing/streams/_default\"); // NOT_FOUND\n// after\nservice.createTable(ref, schema);\nstream = client.createWriteStream(\"projects/p/datasets/d/tables/t/streams/_default\");","handlingStrategy":"retry","validationCode":"// Ensure parent table exists before creating/using a write stream\ntry {\n  service.getTable(tableRef);\n} catch (IOException | InterruptedException e) {\n  throw new IllegalStateException(\"parent table missing in fake: \" + tableRef, e);\n}","typeGuard":null,"tryCatchPattern":"try {\n  stream = client.createWriteStream(streamName);\n} catch (ApiException e) {\n  if (e.getStatusCode().getCode() == io.grpc.StatusCode.NOT_FOUND) {\n    throw new IllegalStateException(\"stream/table not found in fake; check test setup\", e.getCause());\n  }\n  throw e;\n}","preventionTips":["Create datasets/tables in the fake before storage-write operations","Use stream names returned by the fake, not hand-built ones","Reset the fake consistently and re-create resources per test"],"tags":["bigquery","grpc","not-found","storage-write"],"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"}