{"record":{"id":"d671d3188d0adc83","repo":"apache/seatunnel","slug":"failed-to-drop-bigquery-dataset","errorCode":null,"errorMessage":"Failed to drop BigQuery dataset: ","messagePattern":"Failed to drop BigQuery dataset: ","errorType":"exception","errorClass":"CatalogException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-bigquery/src/main/java/org/apache/seatunnel/connectors/bigquery/catalog/BigQueryCatalog.java","lineNumber":351,"sourceCode":"            throw new CatalogException(\"Failed to create BigQuery dataset: \" + databaseName, e);\n        }\n    }\n\n    @Override\n    public void dropDatabase(TablePath tablePath, boolean ignoreIfNotExists)\n            throws DatabaseNotExistException, CatalogException {\n        String databaseName = getDatasetName(tablePath);\n        if (!databaseExists(databaseName)) {\n            if (ignoreIfNotExists) {\n                return;\n            }\n            throw new DatabaseNotExistException(catalogName, databaseName);\n        }\n        try {\n            bigquery.delete(databaseName, BigQuery.DatasetDeleteOption.deleteContents());\n            log.info(\"BigQuery Dataset (database) '{}' dropped successfully.\", databaseName);\n        } catch (Exception e) {\n            throw new CatalogException(\"Failed to drop BigQuery dataset: \" + databaseName, e);\n        }\n    }\n\n    @Override\n    public void truncateTable(TablePath tablePath, boolean ignoreIfNotExists)\n            throws TableNotExistException, CatalogException {\n        if (!tableExists(tablePath)) {\n            if (ignoreIfNotExists) {\n                return;\n            }\n            throw new TableNotExistException(catalogName, tablePath);\n        }\n        String query =\n                String.format(\n                        \"TRUNCATE TABLE `%s.%s` ;\",\n                        getDatasetName(tablePath), tablePath.getTableName());\n        QueryJobConfiguration queryConfig = QueryJobConfiguration.newBuilder(query).build();\n        try {","sourceCodeStart":333,"sourceCodeEnd":369,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-bigquery/src/main/java/org/apache/seatunnel/connectors/bigquery/catalog/BigQueryCatalog.java#L333-L369","documentation":"This CatalogException is thrown by BigQueryCatalog.dropDatabase when bigquery.delete(databaseName, DatasetDeleteOption.deleteContents()) fails. The call attempts to delete a BigQuery dataset along with all of its tables; the exception wraps the underlying API error (permission, not found, concurrent modification, network) while naming the dataset.","triggerScenarios":"Calling dropDatabase(tablePath, ignoreIfNotExists) when the service account lacks bigquery.datasets.delete permission, the dataset was deleted concurrently (404), the BigQuery API returns an unexpected error, or credentials/network fail mid-call.","commonSituations":"Dataset removed by another job/user between the existence check and the delete; read-only or viewer-role service account; dangling dataset references after a failed job; GCP project switched in config so the dataset does not exist there.","solutions":["Inspect the wrapped cause for the real BigQuery error (404 not found, 403 permission)","Verify the service account has bigquery.datasets.delete (e.g. roles/bigquery.dataOwner)","Re-check that the dataset still exists and the configured project/dataset names are correct; pass ignoreIfNotExists=true if races are expected and tolerate 404","Retry on transient 429/5xx errors"],"exampleFix":"// before\ncatalog.dropDatabase(tablePath, false);\n// after\nif (catalog.databaseExists(tablePath)) {\n    catalog.dropDatabase(tablePath, true);\n}","handlingStrategy":"try-catch","validationCode":"if (catalog.databaseExists(tablePath)) {\n    catalog.dropDatabase(tablePath, true);\n}","typeGuard":null,"tryCatchPattern":"try {\n    catalog.dropDatabase(tablePath, true);\n} catch (CatalogException e) {\n    if (e.getCause() instanceof BigQueryException && ((BigQueryException) e.getCause()).getCode() == 404) {\n        LOG.warn(\"Dataset already gone, ignoring\");\n    } else {\n        throw e;\n    }\n}","preventionTips":["Pass ignoreIfNotExists=true and tolerate 404 to handle concurrent deletes","Confirm bigquery.datasets.delete permission before destructive drops","Verify dataset/project identifiers before calling drop","Avoid concurrent jobs dropping the same dataset"],"tags":["bigquery","catalog","dataset-deletion","gcp"],"backgroundTag":"database-write-failed","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}