Skip to content

Commit 1955c7c

Browse files
authored
Destinations: throw error on empty catalog (#39552)
1 parent 7d56e19 commit 1955c7c

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

airbyte-cdk/java/airbyte-cdk/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ corresponds to that version.
174174

175175
| Version | Date | Pull Request | Subject |
176176
|:--------| :--------- | :--------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------- |
177+
| 0.40.2 | 2024-06-18 | [\#39552](https://github.com/airbytehq/airbyte/pull/39552) | Destinations: Throw error if the ConfiguredCatalog has no streams |
177178
| 0.40.1 | 2024-06-14 | [\#39349](https://github.com/airbytehq/airbyte/pull/39349) | Source stats for full refresh streams |
178179
| 0.40.0 | 2024-06-17 | [\#38622](https://github.com/airbytehq/airbyte/pull/38622) | Destinations: Implement refreshes logic in AbstractStreamOperation |
179180
| 0.39.0 | 2024-06-17 | [\#38067](https://github.com/airbytehq/airbyte/pull/38067) | Destinations: Breaking changes for refreshes (fail on INCOMPLETE stream status; ignore OVERWRITE sync mode) |
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version=0.40.1
1+
version=0.40.2

airbyte-cdk/java/airbyte-cdk/typing-deduping/src/main/kotlin/io/airbyte/integrations/base/destination/typing_deduping/CatalogParser.kt

+8-2
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,16 @@ constructor(
2525
private val defaultNamespace: String,
2626
private val rawNamespace: String = JavaBaseConstants.DEFAULT_AIRBYTE_INTERNAL_NAMESPACE,
2727
) {
28-
fun parseCatalog(orginalCatalog: ConfiguredAirbyteCatalog): ParsedCatalog {
28+
fun parseCatalog(originalCatalog: ConfiguredAirbyteCatalog): ParsedCatalog {
29+
if (originalCatalog.streams.isEmpty()) {
30+
throw ConfigErrorException(
31+
"The catalog contained no streams. This likely indicates a platform/configuration error."
32+
)
33+
}
34+
2935
// Don't mutate the original catalog, just operate on a copy of it
3036
// This is... probably the easiest way we have to deep clone a protocol model object?
31-
val catalog = Jsons.clone(orginalCatalog)
37+
val catalog = Jsons.clone(originalCatalog)
3238
catalog.streams.onEach {
3339
// Overwrite null namespaces
3440
if (it.stream.namespace.isNullOrEmpty()) {

airbyte-cdk/java/airbyte-cdk/typing-deduping/src/test/kotlin/io/airbyte/integrations/base/destination/typing_deduping/CatalogParserTest.kt

+9
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package io.airbyte.integrations.base.destination.typing_deduping
55

66
import com.fasterxml.jackson.databind.JsonNode
7+
import io.airbyte.commons.exceptions.ConfigErrorException
78
import io.airbyte.commons.json.Jsons
89
import io.airbyte.protocol.models.v0.AirbyteStream
910
import io.airbyte.protocol.models.v0.ConfiguredAirbyteCatalog
@@ -12,6 +13,7 @@ import io.airbyte.protocol.models.v0.DestinationSyncMode
1213
import io.airbyte.protocol.models.v0.SyncMode
1314
import org.junit.jupiter.api.Assertions
1415
import org.junit.jupiter.api.Assertions.assertAll
16+
import org.junit.jupiter.api.Assertions.assertThrows
1517
import org.junit.jupiter.api.BeforeEach
1618
import org.junit.jupiter.api.Test
1719
import org.mockito.Mockito
@@ -48,6 +50,13 @@ internal class CatalogParserTest {
4850
parser = CatalogParser(sqlGenerator, "default_namespace")
4951
}
5052

53+
@Test
54+
fun throwOnEmptyCatalog() {
55+
assertThrows(ConfigErrorException::class.java) {
56+
parser.parseCatalog(ConfiguredAirbyteCatalog().withStreams(emptyList()))
57+
}
58+
}
59+
5160
/**
5261
* Both these streams will write to the same final table name ("foofoo"). Verify that they don't
5362
* actually use the same tablename.

0 commit comments

Comments
 (0)