Editing a role-bound policy in the UI silently drops actors.roles, leaving the policy active but granting to nobody
Describe the bug
Saving a policy through the UI rewrites its actors from PolicyUpdateInput.ActorFilterInput, which has no roles field. Any role actors on that policy are therefore discarded. The policy stays ACTIVE with its privileges and resource filter intact, but now matches nobody, so every holder of the role silently loses those privileges.
The aspect model does support roles — DataHubActorFilter.roles — and the seeded policies get theirs from the bootstrap step, which writes the dataHubPolicyInfo aspect directly rather than through GraphQL. Since updatePolicy is a full replacement rather than a patch, and the input type cannot express roles, the UI can neither preserve nor restore them.
This is reachable on a default install. boot/policies.json ships five policies with editable: true, and urn:li:dataHubPolicy:editor-metadata-policy-entities is the only one of them bound to a role — so the single role-bound policy DataHub invites administrators to customise is the one that customising breaks.
To Reproduce
Go to Settings → Permissions → Policies
Edit "Editors - Edit Metadata Entities" (
urn:li:dataHubPolicy:editor-metadata-policy-entities)Change anything innocuous — e.g. add a resource type such as
Data process instanceSave
Read the policy back:
{ listPolicies(input: { start: 0, count: 1000 }) { policies { urn state privileges actors { roles users groups allUsers } } } }Result:
{ "urn": "urn:li:dataHubPolicy:editor-metadata-policy-entities", "state": "ACTIVE", "privileges": ["EDIT_ENTITY"], "actors": { "roles": null, "users": [], "groups": [], "allUsers": false } }The resource-type change was applied correctly;
rolesis gone.Any user holding the
Editorrole now gets403on writes the policy used to cover, e.g.POST /aspects?action=ingestProposalfor adataset,dataJobordataProcessInstance.
Expected behavior
Editing an unrelated field of a policy should preserve its actors.roles. A UI that cannot represent a field should not silently delete it.
Impact, and why it is easy to miss
- The policy still looks correct in the UI afterwards — correct state, privileges and resource types. Only
actorsis hollowed out. - Nothing errors. The mutation returns success.
- It is a privilege loss, so it fails closed rather than open — but silently: clients that swallow 403s (the DataHub Airflow plugin's
safe_target, the Great Expectations emitter'sexcept OperationalError: logger.warning(...)) report only warnings, so tasks stay green. - In our case every
EditorlostEDIT_ENTITY, anddataFlow,dataJobanddataProcessInstancewrites all began failing. We only found it in the GMS log, because no client surfaced it.
Root cause
References against master @ 416c4510a57:
| file | what |
|---|---|
datahub-graphql-core/src/main/resources/entity.graphql:10407 |
input ActorFilterInput exposes users, groups, resourceOwners, resourceOwnersTypes, allUsers, allGroups, criteria — no roles |
datahub-graphql-core/src/main/resources/entity.graphql:9944 |
PolicyUpdateInput is a full replacement, not a patch |
datahub-web-react/src/app/permissions/policy/usePolicy.ts:83-90 |
the UI builds actors from exactly those six fields |
metadata-models/src/main/pegasus/com/linkedin/policy/DataHubActorFilter.pdl:72 |
roles: optional array[Urn] — the aspect can hold roles |
metadata-service/war/src/main/resources/boot/policies.json |
five policies are editable: true; only editor-metadata-policy-entities has actors.roles |
So this is a schema omission rather than a logic error: every layer behaves correctly given its inputs, and the data is lost in the gap between the aspect model and the GraphQL input type.
Suggested fix
Either:
- Add
roles: [String!]toActorFilterInput, map it inUpsertPolicyResolver, and populate it inusePolicy.ts— this also makes role actors editable in the UI, which today they are not; or - Preserve the existing
actors.rolesserver-side inUpsertPolicyResolverwhen the input omits the field, so an unrelated edit cannot destroy it.
(1) is the more complete fix. (2) alone would stop the data loss.
A related hardening option: editable: false is unhelpful here as a guard, because SystemPolicyValidator then rejects all modifications from non-system actors — including the direct aspect write needed to repair the damage.
Workaround
Restore actors.roles with a direct write of the dataHubPolicyInfo aspect via ingestProposal, reading the current aspect and changing only that field. GraphQL cannot express it, so the UI cannot be used for the repair.
Version
Observed on v1.7.0; verified still present on master at 416c4510a57 (v1.8.0rc3-168) — both the GraphQL input type and usePolicy.ts are unchanged.
Desktop
Not browser-specific; the behaviour is in the GraphQL schema and the mutation payload.
Source: datahub-project/datahub