Area: Ingestion Issues
Sub-Area: Authorization / Domain-Scoped Policies
Applies to: OSS + Cloud
Issue
You run ingestion as a service account whose metadata policy is scoped to one or more domains. Writes to entities that already exist in that domain succeed. Writes that create new entities fail with HTTP 403. The server message reads:
User <actor urn> is unauthorized to modify entity: HttpStatus: 403 Urn: <entity urn>
This happens most often when a recipe assigns the domain with a domain transformer such as pattern_add_domain, simple_add_domain or pattern_add_dataset_domain.
You Might Be Asking
- Why do my domain-scoped policies work for existing entities but return 403 for new ones?
- Does the order of aspects inside one request matter?
- Why does a domain transformer break ingestion for a domain-scoped service account?
- Can I use a domain-scoped service account for recipe ingestion of new entities?
- Which DataHub version supports domain-scoped creates?
Cause
A domain-scoped policy matches an entity by its domain, plus the parent domains of that domain. For an entity that already has a stored domains aspect, DataHub uses the stored domain.
A new entity has no stored domain. DataHub then uses the domain proposed in the same request: if the request carries a domains aspect for that entity, DataHub matches the policy against that proposed domain. Order inside the request does not matter, because DataHub reads every domains aspect in the request before it checks any write. If the request carries no domains aspect for the new entity, nothing matches the policy and DataHub returns 403. See How to authorize CREATE_ENTITY with a domain-scoped policy.
DataHub checks the whole request before it writes anything. If one entity in a request fails the check, DataHub rejects the whole request with 403, including the writes for other entities in it.
Domain transformers send the domain too late for this check. When the source does not emit a domains aspect for an entity, the transformer remembers the entity and emits its domains aspect at the end of the run. The entity's other aspects (for example datasetProperties or dashboardInfo) go to DataHub earlier, in requests without a domain, and fail with 403.
Proposed-domain matching exists in DataHub Cloud v2.1.2 and later, and in DataHub OSS server v1.8.0 and later. On older servers, a domain-scoped account gets 403 on new entities even when the domains aspect is in the same request.
Solution
-
Check the policy. A domain-scoped writer needs a Metadata policy with these settings:
- Resources: the domain or domains the account writes into. Child domains are included.
- Privileges: Create Entity and Edit Entity.
The domain the writer proposes must be on the policy or be a child of a domain on the policy. A proposed domain outside the policy gets 403.
-
Recipe ingestion (CLI, UI or Remote Executor) with a domain-scoped account is not supported today. This is true when the domain comes from a transformer. It is also true when the domain comes from the source config. The default
datahub-restsink mode (ASYNC_BATCH) fills each request by record count and time, not by entity. An entity's aspects and itsdomainsaspect can go to DataHub in different requests. In theSYNCandASYNCsink modes, each aspect goes in its own request, so every new entity gets 403. When one entity in a request fails the check, DataHub rejects the whole request.An account whose Create Entity and Edit Entity privileges are not scoped to a domain can run recipe ingestion. DataHub then applies the domain as metadata. The DataHub policies docs call this the elevated writer pattern. That account can create and edit entities in any domain, so it does not give you domain isolation. If you need hard isolation between writers, use the Python SDK as described in the next step. See Domain-separated writers vs elevated ingestion. You can also ask DataHub Support to request domain-scoped recipe ingestion as a feature.
-
For the Python SDK, send the entity's aspects and its
domainsaspect in oneemit_mcpscall. One call with a few aspects for one entity goes to DataHub as one request:from datahub.emitter.mce_builder import make_dataset_urn from datahub.emitter.mcp import MetadataChangeProposalWrapper from datahub.emitter.rest_emitter import DatahubRestEmitter from datahub.metadata.schema_classes import DatasetPropertiesClass, DomainsClass emitter = DatahubRestEmitter( gms_server="https://<your-company>.acryl.io/gms", # self-hosted: your GMS URL token="<service-account-token>", ) dataset_urn = make_dataset_urn(platform="<platform>", name="<dataset-name>", env="PROD") domain_urn = "urn:li:domain:<domain-id>" emitter.emit_mcps( [ MetadataChangeProposalWrapper( entityUrn=dataset_urn, aspect=DatasetPropertiesClass(description="My dataset"), ), MetadataChangeProposalWrapper( entityUrn=dataset_urn, aspect=DomainsClass(domains=[domain_urn]), ), ] )This example creates a new dataset. Each wrapper replaces the whole aspect, so don't run it as written against a dataset that already has
datasetPropertiesordomainsyou want to keep. -
If you are on DataHub Cloud older than v2.1.2, or a self-hosted DataHub server older than v1.8.0, upgrade. On DataHub Cloud, contact DataHub Support to schedule the upgrade.
Known Limitations
- Recipe ingestion does not guarantee that an entity's aspects and its
domainsaspect reach DataHub in one request, in any sink mode. A domain-scoped account can get 403 on new entities from recipe ingestion even when the source config sets the domain. - A policy scoped to a domain matches entities in that domain and in its child domains. It does not match entities in a parent or sibling domain. An entity assigned to a domain outside the policy gets 403.
Related Documentation
- Policies: domain-based policy targeting and domain-scoped writers
- Domain-scoped Edit Entity and domains PATCH
- Transformers
- Dataset Transformers
- DataHub Sink
Tags: domain-scoped-policy, 403-error, ingestion, transformers, authorization, new-entity, recipe-ingestion, domains-aspect, create-entity