Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,23 @@ WHERE name IN (
'UsageBotRole')
AND (COALESCE(json ->> '$.provider', '') <> 'system'
OR COALESCE(json ->> '$.allowDelete', '') <> 'false');

-- OrganizationPolicy-NoOwner-Rule names the data asset types anyone may claim when they have no
-- owner. Applied only where the policy has one rule of that name and it is still the shipped one;
-- every other rule is left as stored. ADR:2026-12-02-only-data-assets-can-be-claimed-by-default
UPDATE policy_entity
SET json = JSON_SET(
json,
REPLACE(JSON_UNQUOTE(JSON_SEARCH(json, 'one', 'OrganizationPolicy-NoOwner-Rule', NULL, '$.rules[*].name')), '.name', '.resources'),
JSON_ARRAY('apiCollection', 'apiEndpoint', 'chart', 'container', 'dashboard', 'dashboardDataModel',
'database', 'databaseSchema', 'directory', 'file', 'llmModel', 'mcpServer', 'metric', 'mlmodel',
'pipeline', 'query', 'report', 'searchIndex', 'spreadsheet', 'storedProcedure', 'table', 'topic',
'worksheet'),
REPLACE(JSON_UNQUOTE(JSON_SEARCH(json, 'one', 'OrganizationPolicy-NoOwner-Rule', NULL, '$.rules[*].name')), '.name', '.description'),
'Allow anyone to set the owner of an unowned data asset discovered from a source system.')
WHERE CAST(name AS BINARY) = 'OrganizationPolicy'
AND JSON_LENGTH(JSON_SEARCH(json, 'all', 'OrganizationPolicy-NoOwner-Rule', NULL, '$.rules[*].name')) = 1
AND JSON_EXTRACT(json, REPLACE(JSON_UNQUOTE(JSON_SEARCH(json, 'one', 'OrganizationPolicy-NoOwner-Rule', NULL, '$.rules[*].name')), '.name', '.effect')) = 'allow'
AND JSON_EXTRACT(json, REPLACE(JSON_UNQUOTE(JSON_SEARCH(json, 'one', 'OrganizationPolicy-NoOwner-Rule', NULL, '$.rules[*].name')), '.name', '.condition')) = 'noOwner()'
AND JSON_EXTRACT(json, REPLACE(JSON_UNQUOTE(JSON_SEARCH(json, 'one', 'OrganizationPolicy-NoOwner-Rule', NULL, '$.rules[*].name')), '.name', '.operations')) = JSON_ARRAY('EditOwners')
AND LOWER(CAST(JSON_EXTRACT(json, REPLACE(JSON_UNQUOTE(JSON_SEARCH(json, 'one', 'OrganizationPolicy-NoOwner-Rule', NULL, '$.rules[*].name')), '.name', '.resources')) AS CHAR)) = '["all"]';
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,30 @@ WHERE name IN (
'UsageBotRole')
AND (COALESCE(json ->> 'provider', '') <> 'system'
OR COALESCE(json ->> 'allowDelete', '') <> 'false');

-- OrganizationPolicy-NoOwner-Rule names the data asset types anyone may claim when they have no
-- owner. Applied only where the policy has one rule of that name and it is still the shipped one;
-- every other rule is left as stored. ADR:2026-12-02-only-data-assets-can-be-claimed-by-default
UPDATE policy_entity
SET json = jsonb_set(json, '{rules}', (
SELECT jsonb_agg(
CASE WHEN existing.rule->>'name' = 'OrganizationPolicy-NoOwner-Rule'
AND existing.rule->>'effect' = 'allow'
AND existing.rule->>'condition' = 'noOwner()'
AND existing.rule->'operations' = '["EditOwners"]'::jsonb
AND lower((existing.rule->'resources')::text) = '["all"]'
THEN existing.rule || jsonb_build_object(
'resources', '["apiCollection", "apiEndpoint", "chart", "container", "dashboard", "dashboardDataModel", "database", "databaseSchema", "directory", "file", "llmModel", "mcpServer", "metric", "mlmodel", "pipeline", "query", "report", "searchIndex", "spreadsheet", "storedProcedure", "table", "topic", "worksheet"]'::jsonb,
'description', 'Allow anyone to set the owner of an unowned data asset discovered from a source system.')
ELSE existing.rule END
ORDER BY existing.position)
FROM jsonb_array_elements(json->'rules') WITH ORDINALITY AS existing(rule, position)))
WHERE name = 'OrganizationPolicy'
AND (SELECT count(*) = 1
AND bool_and(r.rule->>'effect' = 'allow'
AND r.rule->>'condition' = 'noOwner()'
AND r.rule->'operations' = '["EditOwners"]'::jsonb
AND lower((r.rule->'resources')::text) = '["all"]')
FROM jsonb_array_elements(
CASE WHEN jsonb_typeof(json->'rules') = 'array' THEN json->'rules' END) AS r(rule)
WHERE r.rule->>'name' = 'OrganizationPolicy-NoOwner-Rule');
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Only data assets can be claimed by default

- **Status:** Accepted
- **Revisions:** v1 2026-12-02 (initial)
- **Deciders:** Adrià Manero
- **Guard:** `OrganizationPolicyDefaultsTest`, `OrganizationPolicyClaimSqlMigrationTest`,
`OrganizationPolicyDefaultsIT`
- **Related:** ADR:2026-11-03-seeded-policies-are-not-reset-on-startup

## Context
The Organization Policy applies to every user. `OrganizationPolicy-NoOwner-Rule` lets anyone set
the owner of an item that has no owner, so that data nobody looks after gets an owner. Data
discovered from source systems arrives with no owner; other items get one when they are created,
or from admins and Data Stewards.

## Decision
- `OrganizationPolicy-NoOwner-Rule` keeps its name, effect, operation (`EditOwners`) and condition
(`noOwner()`), and its `resources` name the data assets discovered from a source system:
`apiCollection`, `apiEndpoint`, `chart`, `container`, `dashboard`, `dashboardDataModel`,
`database`, `databaseSchema`, `directory`, `file`, `llmModel`, `mcpServer`, `metric`, `mlmodel`,
`pipeline`, `query`, `report`, `searchIndex`, `spreadsheet`, `storedProcedure`, `table`, `topic`,
`worksheet`.
- The list lives in the rule, where admins see and change it. The permission engine has no notion
of a data asset, and no deny rule backs the list, so roles an admin grants are not overridden.
- Ingestion pipelines live in a service but are OpenMetadata's own setup, so they are not named.
Governance types (glossaries, domains, test cases and the like) are not named either: admins and
Data Stewards assign their owners.
- An upgrade applies the list through one statement in the post data migration of each line's
next patch release (`2.1.2`, and `2.0.11` on the 2.0 line), with the same text on every line.
It changes only that rule's `resources` and `description`, and only in the policy named exactly
`OrganizationPolicy` whose single rule of that name is still the shipped one: `allow`,
`EditOwners`, `noOwner()`, on `all` in any case. Any other rule is left as stored, and a second
run matches nothing.

## Consequences
- Users with the default roles claim the listed types as before. Admins and Data Stewards set the
owner of other items. Owners set before the upgrade stay.
- A claim rule an admin changed is not migrated: it keeps whatever it names. Admins learn of the
change from the release notes, which say the rule now lists the data asset types and ask admins
who changed it to review its resources. The upgrade logs no warning.
- A new data asset type can be claimed once it is added to the seed and, for upgraded
installations, to a migration statement guarded the same way. `OrganizationPolicyDefaultsTest`
fails when a type with owners and a service is neither listed nor named as an exception.
Loading
Loading