Skip to content

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

Merged
acrylJonny merged 8 commits into
datahub-project:masterfrom
NehaGslab:fix/kafka-subject-external-url
Dec 4, 2026
Merged

acrylJonny merged 8 commits into
datahub-project:masterfrom
NehaGslab:fix/kafka-subject-external-url

Conversation

@NehaGslab

@NehaGslab NehaGslab commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

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.

Written for commit 553fb9f. Summary will update on new commits.

View guided diff

…bjects

With ingest_schemas_as_entities enabled, every subject was given
<external_url_base>/<subject>, a topic path that never exists. The URL
is now built for topics only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added ingestion PR or Issue related to the ingestion of metadata community-contribution PR or Issue raised by member(s) of DataHub Community labels Dec 3, 2026
@cursor

cursor Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

PR Summary

Overview
Stops assigning topic-style externalUrl values to Schema Registry subjects when ingest_schemas_as_entities is enabled alongside external_url_base. Subjects are not navigable under a topic console path, so links like .../orders-value were always broken ("View in Kafka" 404s).

In _emit_dataset, external_url_base is now applied only when not is_subject, so topics still get <base>/<topic> and subject datasets emit no externalUrl. The external_url_base config description notes that schema subjects ingested as entities do not receive an external URL.

A unit test (test_external_url_base_skips_schema_subjects) asserts a topic keeps its URL while a subject entity gets None.

Reviewed by Cursor Bugbot for commit 553fb9f. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions

github-actions Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Linear: ING-4516

Thanks for your contribution! We have created an internal ticket to track this PR. A member of the core DataHub team will be assigned to review it within the next few business days - you will get a follow-up comment once a reviewer is assigned.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 3 files

View guided diff | Re-trigger cubic

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@acrylJonny acrylJonny left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this, LGTM. The fix is right and kept small: the external_url_base block now sits inside the existing if not is_subject: guard, and is_subject is a fixed literal at both call sites, so a topic can't be mistaken for a subject. The regression test fails without the fix and can't pass by skipping the subject. Golden files are unaffected, since the integration recipe doesn't set external_url_base.

A few optional suggestions, none blocking:

  1. kafka.py, the URL block: it's nested inside the catalog-metadata / mirror-lineage block, which has nothing to do with URLs. If someone later adds a condition to that block, every topic would silently lose its link. A flat guard reads better and makes the comment unnecessary:
    if not is_subject and self.source_config.external_url_base:
  2. Subject/topic name collision (existing behaviour, slightly extended here): a subject's dataset_name is its subject name. If a subject is named exactly like a topic (e.g. under a custom subject naming strategy), the two share a URN. Subjects are emitted after topics, so the subject's DatasetProperties replaces the topic's: that already overwrote subtype and custom properties, and now it also blanks the topic's URL. This is rare with the default <topic>-value / <topic>-key naming, so not worth holding the PR for. A follow-up could skip a subject whose URN was already emitted as a topic.
  3. Test file: a full RegisteredSchema is now built inline twice. A small helper would tidy that up, though it isn't worth much for two uses. The Avro schema string could also be trimmed to "fields":[].
  4. Wording nits: the code comment could give the reason ("Schema subjects are not topics, so they have no page under external_url_base"), and the test docstring's "would 404" isn't something the test checks. "Has no page under the topic path" is tighter.

NehaGslab and others added 2 commits December 4, 2026 13:28
Keep the URL check out of the catalog-metadata block so a future condition
there cannot drop topic links.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@NehaGslab

Copy link
Copy Markdown
Contributor Author

@acrylJonny I have addressed the review comments. Can you please review again?

@acrylJonny

Copy link
Copy Markdown
Collaborator

@acrylJonny I have addressed the review comments. Can you please review again?

Thank you. I can see that everything is now addressed - enabling auto-merge.

@acrylJonny
acrylJonny enabled auto-merge (squash) December 4, 2026 08:54
@acrylJonny
acrylJonny merged commit cc47eb5 into datahub-project:master Dec 4, 2026
73 checks passed

This branch was successfully deployed

1 active deployment
Preview — 553fb9f2 Deployed Dec 4, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-contribution PR or Issue raised by member(s) of DataHub Community ingestion PR or Issue related to the ingestion of metadata

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants