fix(ingest/kafka): don't set topic external URL on Schema Registry subjects

Merged
NE
1h ago
+40-2

With ingest_schemas_as_entities: true, the Kafka source emits each Schema Registry subject as its own dataset. The external_url_base handling in _emit_dataset sat outside the if not is_subject: guard immediately above it, so every subject was given the same URL shape as a topic:

<external_url_base>/<subject>   e.g. .../topics/orders-value

A subject is not addressable under a broker's topic path, so that link 404s on every console. In the UI this showed up as a "View in Kafka" button on each subject that never worked.

Fix

Build the external URL only for topics, by moving the external_url_base block inside the existing if not is_subject: guard. Subjects now carry no externalUrl. Topic links are unchanged.

The external_url_base field description now states that it applies to topics only.

Behaviour change

Recipes that combine ingest_schemas_as_entities: true with external_url_base stop emitting an externalUrl on subject datasets. Only a link that never resolved is removed; no recipe changes are needed. Recipes without both settings are unaffected, and the existing Kafka golden files do not change.

Testing

  • New unit test test_external_url_base_skips_schema_subjects: one topic plus one subject with both settings enabled; the topic gets <base>/orders and the subject gets no URL. Confirmed the test fails without the fix.
  • tests/unit/kafka/test_kafka_source_lifecycle.py: all tests pass.
  • Reproduced and verified end to end against a local Kafka + Schema Registry with a file sink and a local Kafka UI as the console:
    • before: orders -> .../all-topics/orders, orders-value -> .../all-topics/orders-value (404)
    • after: orders -> .../all-topics/orders, orders-value -> null

Checklist

  • The PR conforms to DataHub's Contributing Guideline (particularly PR Title Format)
  • Links to related issues (if applicable)
  • Tests for the changes have been added/updated (if applicable)
  • Docs related to the changes have been added/updated (if applicable)
  • For any breaking change/potential downtime/deprecation/big changes an entry has been made in Breaking Changes — not applicable: only a link that never resolved is removed

Summary by cubic

Fixes the Kafka source generating broken externalUrl links on Schema Registry subjects when ingest_schemas_as_entities is enabled. Subjects were given topic-style URLs that always 404; now only topics get an external URL.

Behavior change

  • Datasets emitted for Schema Registry subjects no longer carry an externalUrl, so the "View in Kafka" button no longer appears for them.
  • The external_url_base config description now states it applies to topics only.
  • No recipe changes are required, and existing Kafka golden files are unchanged.