Area: Ingestion Issues
Sub-Area: Tag Entity Registration and Ingestion Configuration
Applies to: OSS + Cloud
Issue
A tag shows on an asset (for example on a dataset column), but you can't find it on the Manage Tags page (Govern > Tags) or in the tag picker when you add tags to another asset.
You Might Be Asking
- Why does a tag show on my column but not in the tag picker?
- Why is a tag missing from Manage Tags even though assets use it?
- I tried to add a description on the tag's page and got "does not exist". Why?
- Tags from my ingestion source disappeared from Manage Tags, and Create Tag says they already exist. Why?
- What is the difference between a tag on an asset and a tag entity?
Cause
DataHub stores two separate things:
- The tag association. This is the
globalTagsaspect on the asset (or the tags on a schema field). It only holds the tag URN, for exampleurn:li:tag:pii. - The tag entity. This is the tag itself, with its own
tagPropertiesaspect (name, description, color).
There are two ways to end up with a tag on an asset but not in Manage Tags.
The tag entity was never created. Your code wrote the association but never created the tag. The asset still shows the tag, because it reads the URN from its own aspect. Manage Tags and the tag picker search the tag index, and a tag that was never created has nothing in that index. This happens with your own emitter or SDK code, or with direct API writes. A recipe run with the DataHub CLI doesn't cause it: the ingestion framework writes a tag entity for every tag that the source puts on an asset.
The tag entity was soft-deleted. A stateful ingestion run set the tag's status aspect to removed: true, which hides it from the UI. See the last section.
You can't fix a never-created tag by editing its description on the tag page. DataHub first checks that the tag exists, and the save fails with Failed to update urn:li:tag:<id>. urn:li:tag:<id> does not exist.
Solution
The tag id is the part of the URN after urn:li:tag:. For urn:li:tag:pii the id is pii. The id is case sensitive. Create the tag with that exact id. The assets that already use the URN then point at a real tag.
Option 1: Create the tag in the UI
You need the Create Tags or Manage Tags privilege.
- Go to Govern > Tags (the Manage Tags page).
- Click Create Tag.
- In the name field, type the tag id exactly as it appears in the URN.
- Save.
The UI uses what you type as both the tag id and the display name, so the new tag gets the same URN as the existing associations. If the tag entity already exists (including a soft-deleted one), creation fails because the tag already exists. In that case go to the soft delete section below.
Option 2: Create tags with the GraphQL API
Use this to create many tags at once, or to set a display name that differs from the id. The createTag mutation takes the id you choose and refuses to overwrite a tag that already exists. See Create Tags.
mutation createTag {
createTag(input: { id: "pii", name: "PII", description: "Personal data" })
}
Send it to https://<your-company>.acryl.io/api/graphql on DataHub Cloud, or http://<your-host>:8080/api/graphql for a self-hosted GMS, with an Authorization: Bearer <your-api-token> header.
To create a list of tags from Python:
from datahub.ingestion.graph.client import DataHubGraph, DatahubClientConfig
graph = DataHubGraph(
DatahubClientConfig(
server="https://<your-company>.acryl.io/gms", # self-hosted: http://<your-host>:8080
token="<your-api-token>",
)
)
CREATE_TAG = """
mutation createTag($input: CreateTagInput!) {
createTag(input: $input)
}
"""
for tag_id in ["pii", "sensitive"]:
try:
result = graph.execute_graphql(
CREATE_TAG, variables={"input": {"id": tag_id, "name": tag_id}}
)
print("Created", result["createTag"])
except Exception as e:
print(f"Not created {tag_id}: {e}")
Option 3: Emit the tag entity from your ingestion code
If your own code writes tag associations, have it also write tagProperties for each new tag URN, so the tag entity exists from the start.
from datahub.emitter.mcp import MetadataChangeProposalWrapper
from datahub.emitter.rest_emitter import DatahubRestEmitter
from datahub.metadata.schema_classes import TagPropertiesClass
emitter = DatahubRestEmitter(
gms_server="https://<your-company>.acryl.io/gms", # self-hosted: http://<your-host>:8080
token="<your-api-token>",
)
tag_urn = "urn:li:tag:pii"
emitter.emit(
MetadataChangeProposalWrapper(
entityUrn=tag_urn,
aspect=TagPropertiesClass(name="PII", description="Personal data"),
)
)
This write replaces the whole tagProperties aspect. If the tag already exists, it overwrites its name and description and clears a color set in the UI. Only emit it for tags that don't exist yet, or use Option 2, which never overwrites.
If the tag existed before and then disappeared: soft delete by stateful ingestion
When a source runs with stateful_ingestion.enabled: true, remove_stale_metadata defaults to true. The run then soft-deletes every entity that the previous successful run emitted and this run did not. See Stateful Ingestion.
This covers tags too. Every tag that the source puts on an asset goes into the source's state, no matter who created the tag. Tags created in the UI or with createTag are included. On the first successful run where the source no longer puts the tag on any asset, the run soft-deletes the tag. The tag disappears from Manage Tags and the tag picker, and Create Tag fails because the tag still exists.
Running the source again does not bring back a tag that the source only puts on assets. The tag stays soft-deleted. A re-run only restores a tag if the source writes the tag's own aspects, such as tagProperties.
To restore the tag, set its status back to removed: false. This patch changes only the removed field. It needs DataHub v1.7.0 or later, or DataHub Cloud v2.1.0 or later:
from datahub.ingestion.graph.client import DataHubGraph, DatahubClientConfig
from datahub.specific.status import StatusPatchBuilder
graph = DataHubGraph(
DatahubClientConfig(
server="https://<your-company>.acryl.io/gms", # self-hosted: http://<your-host>:8080
token="<your-api-token>",
)
)
for mcp in StatusPatchBuilder("urn:li:tag:pii").set_removed(False).build():
graph.emit_mcp(mcp)
On an older server, the server rejects that patch. Write the whole status aspect instead:
from datahub.emitter.mcp import MetadataChangeProposalWrapper
from datahub.metadata.schema_classes import StatusClass
graph.emit_mcp(
MetadataChangeProposalWrapper(
entityUrn="urn:li:tag:pii",
aspect=StatusClass(removed=False),
)
)
Creating or managing the tag outside the pipeline does not stop this, because the source adds the tag to its state as soon as it puts the tag on an asset. To stop it from happening again, do one of these:
- Keep the tag on at least one asset that the source emits on every run.
- Set
remove_stale_metadata: falseunderstateful_ingestionfor that source. This turns off soft deletes for everything that source emits, not only tags.