Repository navigation
feat(mcp): port set_domains and remove_domains - #21506
Conversation
PR SummaryOverview Tests cover happy paths, invalid inputs, GMS errors, registration/annotations, and updated tool-list expectations in the AI service and MCP server tests. Reviewed by Cursor Bugbot for commit f29ad42. Bugbot is set up for automated code reviews on this repo. Configure here. |
75ff4ed to
ea36dae
Compare
7089988 to
80140d4
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 80140d4. Configure here.
set_domains(domain_urn, entity_urns) puts assets in a domain, replacing the domain each one had (an asset belongs to at most one); remove_domains (entity_urns) takes them out of their domain. Both are one batchSetDomain write over all the assets (remove sends a null domain), answer with the number of assets covered and the per-call scope note, and are in the Write metadata group, destructive (a set replaces the previous domain) and idempotent. TOOLS_IS_MUTATION_ENABLED=false hides both. From DataHub Cloud's tools/domains.py: the tools, their descriptions and response shapes (domain_urn, entities_updated, the scope note), the destructive marker and @min_version(oss="1.4.0", cloud="0.3.16"). From the legacy OSS server: entity_urns as a StrList, so a bare URN or a JSON-stringified list is accepted while the schema stays an array (d05ef3d). propose_domain is not ported. Adapted to this package: ToolErrors instead of ValueErrors and RuntimeErrors; the write goes through execute_write (one attempt; no reply means "may or may not have been applied", with what to check); batchSetDomain is in domains.gql, valid on GMS 1.7.0, 1.8.0 and master. The domain must be a domain URN that exists, checked through ReadBackend (DataHub Cloud ran its own entity query); the asset URNs get the same checks add_tags gives them (label_writes.require_entity_urns, now public), so a name or malformed URN fails the whole call, with a search hint, before anything is written. DataHub Cloud's examples used dataFlow and dashboard URNs that do not parse; they are replaced. Tested: unit tests for a set over two assets (input, scope note, the one existence check), remove sending a null domain with no domain check, invalid arguments writing nothing (a name, a tag URN, a missing domain, no assets, a bad asset URN), a false result, a refused write, an unknown outcome, the domain check going through a bound ReadBackend, and through an MCP client a stringified list and the annotations and group. Live on a local OSS DataHub with auth on, through the frontend's /mcp, with a run-unique domain made for the test: set on a dbt and a Postgres orders dataset (both read back in the domain), again with a stringified list; a missing domain, a tag URN and a bare name are tool errors; remove left the Postgres dataset without a domain and a second remove succeeded; a temporary non-admin user's PAT got "DataHub rejected batchSetDomain: Unauthorized ..." from both tools. Both datasets' domains were restored (the dbt one to its original domain) and the test domain was deleted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
create_domain(name, description?, parent_domain?) makes a domain, at the
top level or under an existing domain, and returns {urn, created}. It is
idempotent by name: calling it again with a name that already exists
under the same parent returns that domain with created=false (and a note
when a description was given, since it only applies to a new domain),
while the same name under a different parent is a different domain. It
is in the Write metadata group, not destructive and idempotent.
set_domains' description and its missing-domain message now point at it,
for the create-then-assign flow. TOOLS_IS_MUTATION_ENABLED=false hides
it. New in this package: neither DataHub Cloud nor the legacy OSS server has
it. @min_version(oss="1.4.0", cloud="0.3.16") like the other domain
tools; createDomain and listDomains (with parentDomain) are on GMS 1.7.0.
How it finds an existing domain:
- GMS refuses a second domain with the same name among a parent's direct
children ("... already exists in this domain"). On that refusal the
tool looks the domain up among the parent's children (listDomains with
the parent, or the top-level domains; exact name, as GMS compares) and
returns it. This covers domains made elsewhere, e.g. in the UI.
- GMS's name check runs on the search index, which lags writes: live, two
quick creates of the same name with random ids both passed it and made
two domains. So the tool derives the id from the parent and name (a
UUID5) instead of letting GMS pick a random one, and first reads that
URN's domainProperties directly (ReadBackend.aspects, not search): a
repeated call finds its domain at once. A domain at that id that was
since renamed or moved does not block a new one, which gets a random
id. A known id also lets a create that gets no reply name the URN a
retry will return.
- The parent must be an existing domain (ReadBackend), checked before
writing: GMS's own refusal of a missing parent does not say which URN.
No locks: two concurrent first calls can still race, as in the UI.
ReadBackend gains domains_named(name, parent_domain, count) for the
lookup (findDomainsByName in domains.gql); the test fakes implement it.
Tested: unit tests for a domain under a parent (input, parent check), a
repeated call answered by the direct read with no second write, a domain
moved away from its id not blocking a new one, a duplicate under the same
parent (GMS's refusal, then the lookup under that parent, ignoring a
similar name), a top-level duplicate looked up at the top level, the same
name under another parent created, a conflict whose domain is not found,
invalid arguments creating nothing (blank name, missing parent, non-domain
parent), an unknown outcome naming the URN, other refusals passed on, and
the annotations and set_domains' pointer through an MCP client. Live on a
local OSS DataHub with auth on, through the frontend's /mcp, with
run-unique names: a top-level domain created and the same call again
returned it with created=false and the description note; "Campaigns"
under it created, again returned it; "Campaigns" under a second domain
was a new domain; a domain made directly through GraphQL with a random
id (as the UI does) was found through GMS's name check and returned with
created=false; a missing parent and a bare name are tool errors; a
temporary non-admin user's PAT got "DataHub rejected createDomain:
Unauthorized ..."; the child read back with its parent; set_domains
accepted the new domain; after deleting a domain, creating it again
works. Every test domain was deleted and the dataset's domain removed
again.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
add_owners(owner_urns, entity_urns, ownership_type) makes users and
groups owners of assets with one ownership type; remove_owners
(owner_urns, entity_urns, ownership_type?) takes them off, of one type
or of any. Each is one batch write over all the assets, answering with
the number covered and the per-call scope note. The type is a built-in
(TECHNICAL_OWNER, BUSINESS_OWNER, DATA_STEWARD; also by value, by URN,
or spelled as in the UI, e.g. "technical owner") or a custom type by
its name, case-insensitive, or its URN. Both are in the Write metadata
group and idempotent; remove_owners is destructive.
TOOLS_IS_MUTATION_ENABLED=false hides both.
From DataHub Cloud's tools/owners.py: the tools, their descriptions and
response shapes, built-in and custom type resolution (exact-name match on
listOwnershipTypes, an ambiguous name refused), owner entity types from
the URN, the destructive marker on remove_owners and
@min_version(oss="1.4.0", cloud="0.3.16"). From the legacy OSS server:
ownership_type published as a single-type {"type": "string"} schema
rather than anyOf [enum, string], which constrains nothing and which
Gemini and several OpenAI-compatible endpoints reject, failing the whole
tool list (41ff2dd); owner_urns and entity_urns as StrLists (d05ef3d).
propose_owners is not ported.
Adapted to this package: ToolErrors instead of ValueErrors and
RuntimeErrors; writes through execute_write (one attempt; no reply means
"may or may not have been applied"); mutations and the type lookup in
owners.gql, valid on GMS 1.7.0, 1.8.0 and master. Reads go through
ReadBackend: owner existence (DataHub Cloud ran its own entities query) and a
new ownership_types_named lookup (the test fakes implement it). Owner
URNs must be user or group URNs (a name or another entity's URN is
refused with a search hint) and, for add_owners, exist; remove_owners
does not require that, since removing a deleted user's ownership is how
it gets cleaned up (DataHub Cloud checked both). Duplicate owners are
dropped. Asset URNs get the checks add_tags gives them. A custom type
not found says that search can miss a type made seconds ago and to pass
its URN. The built-in examples now pass strings, as clients do.
A new test in test_mcp_server checks that no registered tool publishes a
parameter whose anyOf/oneOf branches differ in type (nullable is fine),
with every gate open, so a union added later fails there.
Tested: unit tests for a user and a group added to two assets (input
shape, the existence checks), built-in types in four spellings with no
lookup, a custom type by exact name among similar ones, an unknown and
an ambiguous custom type writing nothing, removing any type without an
existence check, removing one type, invalid arguments writing nothing,
a false result, a refused write, an unknown outcome, and through an MCP
client the published ownership_type schemas, stringified lists and the
annotations. Live on a local OSS DataHub with auth on, through the
frontend's /mcp: a user and a group added as technical owners of the
Postgres orders dataset, the same add again ("technical owner", bare and
stringified lists) changed nothing; a data steward added to the dbt
orders dataset and then removed by type left its original owners as they
were; a custom ownership type made for the test (run-unique name) was
used and removed by name in other cases once search had indexed it (two
seconds); a missing user, a bare name and an unknown type are tool
errors; removing all, then again, succeeded; a temporary non-admin
user's PAT got "DataHub rejected batchAddOwners / batchRemoveOwners:
Unauthorized to update owners ...". Both datasets' owners were checked
equal to the originals and the custom type was deleted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
update_description(entity_urn, operation?, description?, column_path?)
replaces, appends to or removes the description of an asset, or of one
of a dataset's columns. It is in the Write metadata group, destructive
and not idempotent (an append adds its text again).
TOOLS_IS_MUTATION_ENABLED=false hides it.
From DataHub Cloud's tools/descriptions.py: the tool, its operations,
description and response shape, the destructive marker and
@min_version(oss="1.4.0", cloud="0.3.16"). From the legacy OSS server:
GraphQL answers an unset aspect with an explicit null, so a null
entity, editableProperties, properties or schemaMetadata reads as no
description instead of raising and being swallowed as a failed read
(e0507ea). propose_description is not ported.
Fixed while porting:
- Append extends the description DataHub shows: the one edited in
DataHub when set, else the one from the source system. DataHub Cloud read
only the edited one for most assets and only the source one for
columns, so appending to an asset documented only at the source, or
to a column with an edited description, replaced the shown text with
the appended text alone.
- A failed read now fails an append before anything is written; DataHub Cloud
treated it as an empty description, which overwrote it the same way.
An append for a type the read does not cover, a missing entity, or a
column not in the schema is refused.
- GMS's updateDescription refuses charts, dashboards, data flows and data
jobs ("Unsupported resource type"), which DataHub Cloud's description
listed; for those the tool uses updateChart / updateDashboard /
updateDataFlow / updateDataJob with editableProperties, as the UI does.
- The description says that "remove" clears the edited description, so
a source-system description comes back into view.
Adapted to this package: ToolErrors instead of ValueErrors and
RuntimeErrors; the entity URN is checked (a name gets a search hint) and
column_path is only accepted for datasets; writes go through
execute_write (one attempt; an append that gets no reply warns that
appending again would add the text twice); the read goes through a new
ReadBackend.description_sources (the test fakes implement it). The
mutations and getDescriptionSources are in descriptions.gql, valid on GMS
1.7.0, 1.8.0 and master.
Tested: unit tests for replace on an asset and a column, remove, a chart
through its own mutation, append to the edited, the source and a
glossary term description and with null aspects, append to a column
(edited field info, source field, null edited description), appends that
cannot read the description writing nothing (missing entity, unsupported
type, a dataset without a schema), a failed read never becoming a
replace, the read going through a bound ReadBackend, invalid arguments,
a false result, a refused write, an unknown outcome on append, and the
annotations through an MCP client. Live on a local OSS DataHub with auth
on, through the frontend's /mcp: on the dbt order_history dataset an
append extended its description, then replace and remove (the source
description showed again); on a column of the dbt orders dataset with
only a source description, two appends extended it and remove cleared
the edited one; a Looker chart's description was replaced and appended
to (updateChart); a run-unique tag made for the test got an append; a
column not in the schema (append, and replace through GMS), a column on
a chart and a missing dataset are errors; a temporary non-admin user's
PAT got "DataHub rejected updateDescription / updateChartDescription:
Unauthorized ...". The dataset's description was restored to its
original text, the chart's editable aspect deleted again (it had none),
the column's edited description left empty (it had none; the source
description shows as before), and the tag deleted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rties
add_structured_properties(property_values, entity_urns) sets typed
structured property values on assets (the given values replace that
property's values; other properties are left as they are);
remove_structured_properties(property_urns, entity_urns) takes
properties off assets. GMS has no batch form, so each asset is one
write; every argument is checked before the first. Both are in the Write
metadata group, destructive and idempotent.
TOOLS_IS_MUTATION_ENABLED=false hides both.
From DataHub Cloud's tools/structured_properties.py: the tools, their
descriptions and response messages, value conversion by the property's
value type (number, string, URN, ISO 8601 date, rich text), the
destructive marker on remove and @min_version(oss="1.4.0",
cloud="0.3.16"). From the legacy OSS server: values published as a
single {"type": "string"} schema while still accepting numbers at
runtime, since Gemini accepts only one type and several OpenAI-compatible
endpoints reject multi-type unions (41ff2dd, 01054c4); the examples pass
numbers as numeric strings; entity_urns and property_urns as StrLists
(d05ef3d). The schema test added with add_owners now also flags a `type`
list with more than one non-null type (01054c4).
propose_structured_properties is not ported.
Fixed while porting:
- A property that does not exist is refused. GMS answers it with
exists=false and a placeholder string definition, which DataHub Cloud's
check (entity is null) let through; live, such a write returned
success and stored nothing.
- A partial failure says which assets were updated and which were not,
with GMS's reason for each (DataHub Cloud listed only the failures, so a
caller could not tell what had changed), and that a retry is safe.
- A single-valued property given several values, and an empty value
list, are refused before writing.
- add_structured_properties is marked destructive (it replaces values).
- remove_structured_properties does not require the property to exist,
as removing tags does not: removing a reference to a deleted property
is how it gets cleaned up.
Adapted to this package: ToolErrors instead of ValueErrors and
RuntimeErrors; writes through execute_write (one attempt each; no reply
is reported per asset as "may or may not have been applied"); asset URNs
get the checks add_tags gives them; the definition read goes through a
new ReadBackend.structured_property (the test fakes implement it). The
mutations and getStructuredPropertyDefinition are in
structured_properties.gql, valid on GMS 1.7.0, 1.8.0 and master.
Tested: unit tests for four typed properties on two assets (the inputs
sent), invalid values writing nothing (no properties, a non-property
key, a missing property as GMS answers it, no values, a non-number, two
values for a single-valued property, a non-URN, a non-ISO date), a bad
asset URN, a partial failure (one applied, one refused, one without a
reply), remove with duplicates and no definition reads, an empty result,
the read through a bound ReadBackend, and through an MCP client the
published value schema, an integer value, a bare entity URN and the
annotations. Live on a local OSS DataHub with auth on, through the
frontend's /mcp: a run-unique multi-valued property made for the test
and the showcase dataQualityScore set on the Postgres and S3 orders
datasets (read back), an integer score accepted; a non-number, two
values for a single-valued property, a non-URN, a missing property and
a value outside GMS's allowed values are errors; a missing dataset among
two got "applied to 1 of 2" with GMS's reason; remove took the test
property off both, and again; a temporary non-admin user's PAT got
"Not authorized to update properties" from both tools. Both datasets'
properties were checked equal to the originals and the test property
was deleted (soft, then hard, as this GMS requires).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
save_document(document_type, title, content, urn?, topics?,
related_documents?, related_assets?, parent_urn?) saves a standalone
document (an insight, decision, FAQ, ...) to DataHub's knowledge base.
Without `urn` it creates a new document, owned by the caller, under
`parent_urn` or else under a shared folder the tool keeps ("Shared",
optionally with a subfolder per author). With the `urn` of a stored
document it replaces that document's title, body and type in place and
keeps everything else: parent, owners, status, visibility, created
stamp, and the topics and related links not passed. It is in the Write
metadata group, destructive and not idempotent (each create is a new
document). TOOLS_IS_MUTATION_ENABLED=false or SAVE_DOCUMENT_TOOL_ENABLED
=false hides it.
From DataHub Cloud's tools/save_document.py and
document_edit_policy.py: the tool and its description, `parent_urn` for
new documents (a parent must exist; setting it on an update is refused,
moves are update_document's), the in-place update that fixes the
re-parenting of the legacy OSS server's version (it rebuilt the
document on every update, which moved it into the shared folder and
reset its status, created stamp and visibility), restoring a
soft-deleted shared folder (also legacy OSS c978c57), DocumentSettings
stamped with the caller on every save, certification left out of the
upsert, the retrieval-policy configuration guard, the host edit policy
(entry point datahub.mcp.document_edit_policy) and its pre-approval
validator, and the gates with DataHub Cloud's defaults:
SAVE_DOCUMENT_TOOL_ENABLED on, SAVE_DOCUMENT_RESTRICT_UPDATES off (when
on, only documents inside the shared folder may be updated),
SAVE_DOCUMENT_ORGANIZE_BY_USER off, SAVE_DOCUMENT_PARENT_TITLE "Shared".
@min_version(oss="1.4.0", cloud="0.3.16"). From the legacy OSS server:
topics, related_documents and related_assets as OptionalStrLists (a
bare or stringified list is accepted; "" and "null" count as omitted)
(d05ef3d, 01054c4). DataHub Cloud's MemorySynthesizer helper
(create_user_scoped_document) is not a tool and is not ported.
version_requirements gains @pre_approval_validator, which sets the
attribute approval hosts read.
Fixed while porting, so a failed or partial save never creates a
duplicate or re-parents a document:
- A failed read of the document to update (existence or fetch) stops
the call; DataHub Cloud could fall through to creating it again in the
shared folder.
- A shared folder that cannot be created or restored stops the save,
instead of saving the document under a missing (hidden) folder.
- Writes are single attempts: a refusal gives GMS's reason (the
validator's message for a rejected aspect), and no reply says the
save may or may not have been applied, naming the URN; for a create
it says to retry with urn=<that URN>, which updates instead of making
a second document.
- related_documents must be document URNs and related_assets URNs;
blank topics are dropped; SDK usage errors become tool errors.
Adapted to this package: reads go through ReadBackend (existence,
folder status and the shared-folder ancestry via aspects); the caller is
read with getDocumentAuthor in document_writes.gql (valid on GMS 1.7.0,
1.8.0 and master); loguru; ToolErrors throughout.
Tested: unit tests against a fake catalog with real SDK documents: a new
document in the shared folder (owner, tags from topics, related asset,
settings actor), new URNs per create, a missing shared folder created
first, a soft-deleted one restored, a folder that cannot be created
stopping the save, a new document under a given parent, invalid
arguments writing nothing, a create without a reply naming the URN to
retry with; an update in place keeping parent, status, visibility,
related assets and owners with no folder touched, an update replacing
the lists it is given, a refused update written once with its original
parent and never turned into a create, an update without a reply, an
update whose document cannot be read (exists or get) writing nothing, an
unknown URN created at that URN, SAVE_DOCUMENT_RESTRICT_UPDATES, a
locked field refused by the pre-approval validator and the tool, the
registration (annotations, group, stringified lists) and the gate on and
off. Live on a local OSS DataHub with auth on, through the frontend's
/mcp, with run-unique titles: a new insight landed in a newly created
"Shared" folder with its tag, related asset and owner; a document
created under another test document as parent, then updated through
save_document in place (same URN, title, body and type replaced, parent
and owners kept); parent_urn on an update, a missing parent and a
dataset URN as a related document are errors; a given unknown URN was
created there; a temporary non-admin user's PAT got "DataHub rejected
saving ...: ... unauthorized to modify entity" for a create and an
update, and the update left the document unchanged. All test documents
and the shared folder (absent before the test) were hard-deleted
(deleteDocument only soft-deletes).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
update_document(urn, command, ...) changes part of an existing document
without sending it whole: update_content applies anchored {old_str,
new_str, replace_all_matches?} edits to the body; replace_content
replaces the body (allow_deleting_content=true is required when there
is one); append_content adds to the end; update_properties changes
title, topics, related documents, related assets or status
(PUBLISHED / UNPUBLISHED) without the body; move puts the document,
with what is nested under it, under another document. Every command but
move edits the stored document in place, keeping its parent, owners and
visibility. It is in the Write metadata group, destructive and not
idempotent, and is registered with save_document behind the same gates
(TOOLS_IS_MUTATION_ENABLED, SAVE_DOCUMENT_TOOL_ENABLED, both on by
default).
From DataHub Cloud's tools/update_document.py: the commands and their
argument checks (an argument of another command names the command that
owns it; a missing or empty required one shows its shape), the anchored
edit rules, the replace guard, moves through GMS's moveDocument (which
refuses a missing parent and a loop under the document's own
descendant; an upsert of documentInfo would not), the
SAVE_DOCUMENT_RESTRICT_UPDATES guardrail (off by default) also applied
to a move's target, the configuration-document guard, the host edit
policy with its pre-approval validator, lastModified stamped with the
caller, certification left out of the upsert, and
@min_version(oss="1.4.0", cloud="0.3.16"). The legacy OSS server's
version lacks move and the in-place guarantees; its separate
MCP_UPDATE_DOCUMENT_ENABLED gate is not ported (DataHub Cloud dropped it: the
two tools ship together).
So a failed update never re-parents a document or creates one: a
missing document is refused (use save_document to create); a failed
read stops the call before any write; a refused or failed move writes
nothing else; a content or property write is one upsert of the stored
document in its own folder, never retried, with GMS's reason on a
refusal and "may or may not have been applied" when there is no reply
(for an append, a warning that appending again would add the text
twice). SDK usage errors become tool errors.
Adapted to this package: shared helpers from save_document.py (write
handling, the caller, guards); existence read through ReadBackend;
moveDocument in document_writes.gql (valid on GMS 1.7.0, 1.8.0 and
master); ToolErrors throughout.
Tested: unit tests for anchored edits (one and replace-all) changing only
the body, edits that do not anchor (missing, ambiguous, no old_str)
writing nothing, the replace guard, append, update_properties leaving the
body (tags, status, settings actor), move through moveDocument with no
other write, a refused move changing nothing, arguments that do not fit
the command, a missing document not created, a failed read, a refused
update written once in its own folder, an append without a reply, the
shared-folder guardrail, a locked field refused before approval and by
the tool, and registration with save_document behind one gate. Live on a
local OSS DataHub with auth on, through the frontend's /mcp, on
run-unique test documents: an anchored edit, ambiguous and missing
anchors refused, replace refused then confirmed, append, title, topic and
status changed, all with the parent and owner unchanged; a foreign
argument and a missing document are errors; a temporary non-admin user's
PAT got "unauthorized to modify entity" for an append and "DataHub
rejected moveDocument: Unauthorized" for a move, and the document was
unchanged; a move to another folder worked, a move under the document's
own child got "would create a circular parent reference" and a move
under a missing document "does not exist", both leaving the parent as
it was. All test documents and the shared folder (absent before) were
hard-deleted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
80140d4 to
f29ad42
Compare
ea36dae to
bbf2777
Compare
7383f0c
into
na--mcp-create-glossary-term-version

Stack. This is one PR in a series that adds a built-in MCP server to DataHub Core. It is based on
na--mcp-create-glossary-term-version(the previous PR in the stack); review only its own commit. It changes only the shareddatahub-core-mcp-toolspackage anddatahub-ai-service. It is one tool port, so it stays one PR even where it runs past the stack's usual 1,000-line size. Everything user-facing is behind a GMS feature flag,MCP_SERVER_ENABLED, off by default (added in #21349).Stack so far:
1–22. Merged to
masteras #21332.23–34. #21435, the read tools (PRs 24–34 merged into it).
35. #21501
36. #21502
37. #21503
38. #21504
39. #21505
40. #21506 ← this PR
41. #21507
42. #21508
43. #21509
44. #21510
45. #21511
46. #21512
47–55. #21587, MCP settings: model, API and UI.
56–60. #21588, telemetry, metrics, usage events and the stdio server.
61–64. #21589, docs, release notes and smoke tests.
65–68. #21590, settings enforcement and the tool catalog.
69–70. #21591, the home page module.
What this does
set_domains(domain_urn, entity_urns) puts assets in a domain, replacing
the domain each one had (an asset belongs to at most one); remove_domains
(entity_urns) takes them out of their domain. Both are one batchSetDomain
write over all the assets (remove sends a null domain), answer with the
number of assets covered and the per-call scope note, and are in the
Write metadata group, destructive (a set replaces the previous domain)
and idempotent. TOOLS_IS_MUTATION_ENABLED=false hides both.
From DataHub Cloud's tools/domains.py: the tools, their descriptions
and response shapes (domain_urn, entities_updated, the scope note), the
destructive marker and @min_version(oss="1.4.0", cloud="0.3.16"). From
the legacy OSS server: entity_urns as a StrList, so a bare URN or a
JSON-stringified list is accepted while the schema stays an array
(d05ef3d). propose_domain is not ported.
Adapted to this package: ToolErrors instead of ValueErrors and
RuntimeErrors; the write goes through execute_write (one attempt; no
reply means "may or may not have been applied", with what to check);
batchSetDomain is in domains.gql, valid on GMS 1.7.0, 1.8.0 and master.
The domain must be a domain URN that exists, checked through ReadBackend
(DataHub Cloud ran its own entity query); the asset URNs get the same checks
add_tags gives them (label_writes.require_entity_urns, now public), so a
name or malformed URN fails the whole call, with a search hint, before
anything is written. DataHub Cloud's examples used dataFlow and dashboard URNs
that do not parse; they are replaced.
Testing
unit tests for a set over two assets (input, scope note, the one
existence check), remove sending a null domain with no domain check,
invalid arguments writing nothing (a name, a tag URN, a missing domain,
no assets, a bad asset URN), a false result, a refused write, an unknown
outcome, the domain check going through a bound ReadBackend, and through
an MCP client a stringified list and the annotations and group. Live on
a local OSS DataHub with auth on, through the frontend's /mcp, with a
run-unique domain made for the test: set on a dbt and a Postgres orders
dataset (both read back in the domain), again with a stringified list; a
missing domain, a tag URN and a bare name are tool errors; remove left
the Postgres dataset without a domain and a second remove succeeded; a
temporary non-admin user's PAT got "DataHub rejected batchSetDomain:
Unauthorized ..." from both tools. Both datasets' domains were restored
(the dbt one to its original domain) and the test domain was deleted.
Checklist
🤖 Generated with Claude Code