Skip to content

Fixes #34181: resolve inline child collections through one registry and serve them on every entity type - #34182

Merged
Shreyansh100704 merged 41 commits into
mainfrom
feat/generalize-ai-automations
Sep 30, 2026
Merged

Shreyansh100704 merged 41 commits into
mainfrom
feat/generalize-ai-automations

Conversation

@Shreyansh100704

@Shreyansh100704 Shreyansh100704 commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Describe your changes:

Fixes #34181

I worked on unifying how the server reaches an entity's inline child collection — table columns, topic schema fields, container data-model columns, ML features, pipeline tasks, search-index fields, API-endpoint request/response fields, worksheet columns — because each of nine call sites carried its own hardcoded entity-type switch, and /v1/columns only served two of those types. Everything else had no read or write path for its children at all, which is what blocked AI Automations from working on any asset but tables.

ChildFieldResolver is now the single registry naming each type's child container(s), and every consumer reads it: FieldPathUtils, LineageRepository.getChildrenNames, getParentEntityFQN, DataContract schema validation, the ES/OS column-grid configs and ColumnRepository. /v1/columns reads and writes all nine types, and each entity resource gains a paginated GET /name/{fqn}/columns backed by one shared ChildFieldPageReader. Task and MlFeature implement FieldInterface so they travel the same paths, and a columns alias lets one caller address any type's children uniformly.

Two fixes ride along. Entity pages other than Table were never wrapped in SuggestionsProvider, so a valid AI suggestion on a dashboard, topic, ML model, container, search index, API endpoint or pipeline was created and then silently invisible — useSuggestionsContext returns {} with no provider, so consumers render nothing rather than failing. And FieldPathUtils resolved a child by name, first match wins; since the columns alias concatenates an apiEndpoint's two schemas, which normally share field names, an accepted suggestion for one schema's field silently overwrote the other's. It now refuses an ambiguous name instead of guessing.

ML feature tags now live in tag_usage, like every other entity's child tags. MlModelRepository overrides applyTags / applyTagsToEntities to write each feature's tags under its FQN, hydrates them back in setFields via populateEntityFieldTags plus a bulk fetchAndSetFeatureTags, and storageJsonNode strips them from the stored JSON. MlModelUpdater.updateMlFeatures pairs features by name (it used whole-object equals, so any edited feature was skipped) and reindexes tags for features added or removed in a patch.

Migration MlFeatureTagBackfill (v210, MySQL + Postgres) indexes existing feature tags, since applyTags only fires on write. It reads the stored JSON, never modifies it, writes through the same tagUsageDAO.applyTag the runtime uses so the FQN hashing cannot drift, skips DERIVED labels, and derives a feature's FQN when an older row lacks one. Idempotent (INSERT IGNORE / ON CONFLICT DO NOTHING). It fails the upgrade if it cannot complete: with feature tags stripped from the JSON, tag_usage is their only home, so a model the backfill did not reach reads as untagged and the next write of it deletes the JSON copy too. A migration recorded as complete never re-runs on its own, so swallowing the failure would turn it into silent permanent loss.

Type of change:

  • Bug fix
  • Improvement

High-level design:

Approach. Extract the knowledge that was duplicated (which property holds a type's children) into a declarative registry, then convert each consumer one at a time, each conversion preceded by a characterization test committed against the old behaviour. That makes the refactor provably a no-op for the paths it replaces, which matters because these paths back lineage, data contracts and search indexing.

Key components.

  • ChildFieldResolver — entityType → container paths + child class + parent FQN depth. Charts are deliberately absent: a chart is a separate entity with its own RBAC.
  • CHILD_CONTAINER_ALIAS ("columns") — one segment any caller may use to mean "this entity's children", whatever the container is actually called. Needed because suggestion field paths are built as columns.<name>.<property> for every type.
  • ChildFieldPageReader — one paging/sorting/enrichment implementation, with a ChildPageEnricher hook so the table path keeps its custom metrics, extensions and PII-masked profiles while the other eight need nothing beyond tags.

Alternatives rejected. Aliasing only where the direct lookup fails (correctness would then depend on which reflective getters happen to exist — the accident that produced the original bug); and a protected hook on EntityRepository (that class has no authorization dependency and is inherited by many repositories with no child collection at all).

Compatibility. The table endpoint's wire shape is frozen by test. Authorization is unchanged: each new endpoint authorizes VIEW_BASIC on the parent via getResourceContextByName, matching what the table endpoint has always done, and the generic reader passes ChildPageEnricher.NONE, so no masked-data path exists to bypass.

Tests:

Use cases covered

  • Reading a paginated child page for each of the nine registry types, sorted and with tags.
  • Writing a description, display name, tag or glossary term to a child of any of them through /v1/columns.
  • Accepting an AI description suggestion on a non-table asset and seeing it applied.
  • Viewing and accepting a suggestion on all seven non-table entity pages in the UI.
  • Approving a suggestion whose field name is ambiguous — it is refused, not mis-applied.

Unit tests

  • Added for new/changed logic, plus characterization tests for every refactored path.
  • Files: ChildFieldResolverTest, FieldPathUtilsTest, ColumnRepositoryValidationTest, ColumnGridIndexConfigsTest, MigrationUtilTaskWorkflowTest, TaskWorkflowHandlerTest, TaskWorkflowLifecycleResolverTest, plus the pinned pre-refactor characterizations for LineageRepository.getChildrenNames, getParentEntityFQN (quoted-dotted segments and struct grandchildren), the DataContract extractors and the grid aggregators.

Backend integration tests

  • Added: per-entity child columns endpoints, the child-field resolution edge matrix, and the frozen paginated wire shape for table and dashboardDataModel.
  • Helpers added: DenyPolicyPrincipals (negative authz), UriTestUtils (raw HTTP).

Ingestion integration tests

  • Not applicable (no ingestion changes).

Playwright (UI) tests

Manual testing performed

  1. Against a running stack, read GET /name/{fqn}/columns for all nine types and confirmed each returns its own children (table 12, dashboardDataModel 5, topic 10, container 3, pipeline 1, mlmodel 3, searchIndex 3, apiEndpoint 16, dashboard 2 charts).
  2. Wrote tags to requestSchema.email and responseSchema.email on one API endpoint and confirmed both landed independently despite the shared field name.
  3. Created a real Suggestion task with fieldPath=columns.email.description on that endpoint (two matches) and approved it: HTTP 200, nothing written, both fields untouched. Control with columns.full_name.description (one match): approved and applied. Fixture restored afterwards.

UI screen recording / screenshots:

Not applicable.

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR title is Fixes #34181: resolve inline child collections through one registry and serve them on every entity type
  • My PR is linked to a GitHub issue via Fixes #34181 above.
  • I have commented on my code, particularly in hard-to-understand areas.
  • For JSON Schema changes: Task and MlFeature gained a FieldInterface marker only — no stored shape changed, so no migration is needed.
  • For UI changes: no visual change; see above.
  • I have added tests and listed them above.
  • Tests cover the exact scenarios being fixed (the ambiguous-name write, and the missing provider on each of the seven pages).

Copilot AI balanced review requested due to automatic review settings September 28, 2026 21:46
@Shreyansh100704
Shreyansh100704 requested a review from a team as a code owner September 28, 2026 21:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@manerow manerow left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving the nine per-type switches onto one registry, with characterization tests committed before each change, made this much easier to review. I left two comments I think should be fixed before merging: bulk column updates report saved changes as failed for children that aren't table-style columns, and ML feature tags come back empty from the new paginated endpoint when fields=tags is requested. The rest (authorization, lineage, data contract validation, and the table endpoint's response shape) looks good to me.

String columnFQN,
String entityType,
UpdateColumn updateColumn) {
return (Column)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bulkUpdateColumns (line 777) still calls this method, and this cast runs after updateChildByFQN has already saved the patch and the change event. For a topic field, search index field, pipeline task or ML feature, the cast throws ClassCastException. The bulk loop catches it and reports the row as failed, even though the change was saved.

This is reachable from the existing UI: in Column Bulk Operations, filter by Asset type "Topic" or "Search Index", select a few rows, edit the description and save. The job reports every row as failed ("class ...Field cannot be cast to class ...Column"), but the descriptions did change. CSV import (line 946) calls the same method, so it behaves the same way. Before this PR these rows failed with "Unsupported entity type" and nothing was written, so at least the result was reported correctly.

List<FieldInterface> page = new ArrayList<>(sorted.subList(bounds[0], toIndex));

if (fieldsParam != null && fieldsParam.contains("tags")) {
Entity.populateEntityFieldTags(spec.entityType(), page, parent.getFullyQualifiedName(), true);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With fields=tags, this reads each child's tags from the tag_usage table and sets them to an empty list when it finds none there. That works for eight of the nine types, but ML model features keep their tags only inside the model's stored JSON. MlModelRepository never writes feature tags to tag_usage: it has no applyTags override, unlike Topic, Pipeline, SearchIndex, Container, APIEndpoint and Worksheet. So GET /v1/mlmodels/name/{fqn}/columns?fields=tags would return every feature with tags: [], even when it has tags.

This matters for the automation use case. PUT /v1/columns replaces the whole tag list, so a caller that reads the tags from this endpoint, adds one and writes the list back would drop the feature's existing tags.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@gitar-bot

gitar-bot Bot commented Sep 30, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 3 closed / 3 findings

🔴 High risk · Migration moves ML feature tags into tag_usage, making backfill completeness data-critical.

Unifies how the server resolves inline child collections (table columns, topic schema fields, container data-model columns, ML features, pipeline tasks, search-index fields, API-endpoint request/response fields, worksheet columns) through a single ChildFieldResolver registry, making /v1/columns serve all nine types and adding paginated GET /name/{fqn}/columns endpoints for each. Fixes tag suggestions writing to the first match for ambiguous child names by refusing ambiguous field paths instead, indexes feature tags on bulk-created ML models, and adds a mandatory migration backfill (v210) that indexes existing feature tags with failure propagation to prevent silent permanent loss. No issues found.

✅ 3 closed
✅ Bug: Tag suggestions still write to the first match for ambiguous child names

📄 openmetadata-service/src/main/java/org/openmetadata/service/util/FieldPathUtils.java:367-381 📄 openmetadata-service/src/main/java/org/openmetadata/service/util/ChildFieldResolver.java:227-240
The ambiguity guard from commit 00ab46e only runs in setDescriptionInList and getDescriptionFromList. findField → locateField → findFieldInList never calls isAmbiguous, so it still returns the first child whose name matches. TaskWorkflowHandler.patchFieldTags relies on findField. On an apiEndpoint, the columns alias joins the request and response schemas, so an approved tag suggestion such as columns.email.tags writes tags onto whichever email field comes first and reports success. That's the silent mis-write the PR says it fixed, just through tags instead of descriptions. To fix it, add the same isAmbiguous check at the top of findFieldInList and return Optional.empty() when it fires, so the tag path refuses the write the way the description path does.

✅ Bug: Bulk-created ML models lose feature tags: stripped but never indexed

📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/MlModelRepository.java:332-346
storageJsonNode now removes tags from every feature before the model is stored. The only thing that writes those tags to tag_usage is the per-entity applyTags(MlModel) override. The bulk create path (createManyEntities → storeRelationshipsInternal(List<T>)) never calls that override. It calls applyTagsToEntities(entities), which indexes only entity.getTags() at the model level. MlModelRepository doesn't override it, while TableRepository does so its column tags get indexed. So any ML model created through the bulk API ends up with its feature tags neither in the stored JSON nor in tag_usage, and they are lost for good. Fix: override applyTagsToEntities so it also collects each feature's non-derived tags under the feature FQN, the same way TableRepository collects column tags.

✅ Bug: Backfill swallows failures, then the next write erases JSON feature tags

📄 openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v210/MlFeatureTagBackfill.java:74-79 📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/MlModelRepository.java:113-118 📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/MlModelRepository.java:332-343
backfillMlFeatureTags catches every exception and only logs it. Its comment says the tags are safe because they "remain in the model JSON… until this is re-run". That stops being true once this commit is deployed. Any read with fields=tags hydrates features from tag_usage and gets an empty list for rows that were never backfilled. After that, any PUT or PATCH of the model saves the features through storageJsonNode, which strips tags, so the JSON copy is deleted as well. The v210 migration is recorded as complete, so it never re-runs by itself. A partial or failed backfill therefore turns into permanent tag loss on the next edit. Fix: let the exception propagate so the migration fails and can be retried. At minimum, don't record success, and correct the comment.

Review coverage

📋 Rules No rules evaluated

🧪 Functional validation Not enabled · Set up

🤖 Auto-approval Not enabled · Set up

Options

Display: compact → Counting what did not apply, without listing it.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@sonarqubecloud

Copy link
Copy Markdown

@sonarqubecloud

Copy link
Copy Markdown

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe to test Add this label to run secure Github workflows on PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Automations is limited to tables because child-field read/write is table-only

5 participants