diff --git a/metadata-ingestion/src/datahub/ingestion/source/kafka/kafka.py b/metadata-ingestion/src/datahub/ingestion/source/kafka/kafka.py index a8a876adb37c7..810e3854a4baa 100644 --- a/metadata-ingestion/src/datahub/ingestion/source/kafka/kafka.py +++ b/metadata-ingestion/src/datahub/ingestion/source/kafka/kafka.py @@ -1414,7 +1414,8 @@ def _emit_dataset( if mirror_lineage is not None: extra_aspects.append(mirror_lineage) - if self.source_config.external_url_base: + # Schema subjects are not topics, so they have no page under external_url_base. + if not is_subject and self.source_config.external_url_base: base_url = self.source_config.external_url_base.rstrip("/") external_url = f"{base_url}/{dataset_name}" diff --git a/metadata-ingestion/src/datahub/ingestion/source/kafka/kafka_config.py b/metadata-ingestion/src/datahub/ingestion/source/kafka/kafka_config.py index 43c9a84f05d8c..fd6cfb3a20107 100644 --- a/metadata-ingestion/src/datahub/ingestion/source/kafka/kafka_config.py +++ b/metadata-ingestion/src/datahub/ingestion/source/kafka/kafka_config.py @@ -380,7 +380,7 @@ class KafkaSourceConfig( ) external_url_base: Optional[str] = Field( default=None, - description="Base URL for external platform (e.g. Aiven) where topics can be viewed. The topic name will be appended to this base URL.", + description="Base URL for external platform (e.g. Aiven) where topics can be viewed. The topic name will be appended to this base URL. Schema Registry subjects ingested with `ingest_schemas_as_entities` get no external URL.", ) profiling: ProfilerConfig = Field( default_factory=ProfilerConfig, diff --git a/metadata-ingestion/tests/unit/kafka/test_kafka_source_lifecycle.py b/metadata-ingestion/tests/unit/kafka/test_kafka_source_lifecycle.py index 78f468b69b305..76b094a4bcd88 100644 --- a/metadata-ingestion/tests/unit/kafka/test_kafka_source_lifecycle.py +++ b/metadata-ingestion/tests/unit/kafka/test_kafka_source_lifecycle.py @@ -187,6 +187,43 @@ def test_external_url_base_links_each_topic( assert props.externalUrl == "https://console.example.com/topics/orders" +def test_external_url_base_skips_schema_subjects( + kafka_clients: KafkaClientMocks, make_kafka_source: SourceFactory +) -> None: + """A Schema Registry subject has no page under the topic path, so it gets no + external URL.""" + kafka_clients.set_topics(["orders"]) + kafka_clients.registry.return_value.get_subjects.return_value = ["orders-value"] + kafka_clients.registry.return_value.get_latest_version.return_value = ( + RegisteredSchema( + schema_id=1, + guid=None, + schema=Schema( + schema_str='{"type":"record","name":"Order","fields":[]}', + schema_type="AVRO", + ), + subject="orders-value", + version=1, + ) + ) + + source = make_kafka_source( + { + "external_url_base": "https://console.example.com/topics/", + "ingest_schemas_as_entities": True, + } + ) + urls = { + props.name: props.externalUrl + for props in emitted_aspects(source, DatasetPropertiesClass) + } + + assert urls == { + "orders": "https://console.example.com/topics/orders", + "orders-value": None, + } + + def test_one_failing_topic_does_not_abort_the_run( kafka_clients: KafkaClientMocks, make_kafka_source: SourceFactory ) -> None: