Skip to content

Fixes 30533: Map AI and context entity types to their schema subdirectories - #30534

Closed
jun-su-lee wants to merge 3 commits into
open-metadata:mainfrom
jun-su-lee:fix/schema-field-extractor-entity-subdirectories
Closed

Fixes 30533: Map AI and context entity types to their schema subdirectories#30534
jun-su-lee wants to merge 3 commits into
open-metadata:mainfrom
jun-su-lee:fix/schema-field-extractor-entity-subdirectories

Conversation

@jun-su-lee

@jun-su-lee jun-su-lee commented Jul 27, 2026

Copy link
Copy Markdown

Describe your changes:

Fixes #30533

SchemaFieldExtractor.getEntitySubdirectory() maps an entity type to the subdirectory that holds its JSON schema and falls back to "data". Six entity types are missing from that map, so their schemas are looked up under json/schema/entity/data/ and fail to load — each one logs an ERROR on every server startup and is skipped by field extraction:

Entity type Actual location Looked up at
mcpServer json/schema/entity/ai/ json/schema/entity/data/
mcpExecution json/schema/entity/ai/ json/schema/entity/data/
aiGovernanceFramework json/schema/entity/ai/ json/schema/entity/data/
aiFrameworkControl json/schema/entity/ai/ json/schema/entity/data/
auditReport json/schema/entity/ai/ json/schema/entity/data/
contextMemory json/schema/entity/context/ json/schema/entity/data/

The issue was filed for mcpServer / mcpExecution because those are the two that exist in 1.13.1; the other four were added after that release and have the same problem on main. contextMemory also lives in a subdirectory (context) that the map does not know about at all.

Entity types are discovered by scanning json/schema/entity/ with ClassGraph in getAllEntityTypes(), while loading goes through the hardcoded map — so the two can drift, and they have drifted six times. Besides adding the missing entries, this PR adds a test that walks every discovered entity type and asserts its resolved schema path exists on the classpath, so an entity added under a new subdirectory fails CI instead of silently logging errors at runtime.

Removing the map entirely and reusing the paths that the ClassGraph scan already knows would eliminate this class of bug rather than detect it. I kept that out of this PR to keep the change small — happy to follow up separately if maintainers want it.

Type of change:

  • Bug fix

High-level design:

N/A — small change.

Tests:

Use cases covered

  • Server startup no longer logs Schema file not found at path: json/schema/entity/data/<entityType>.json for the six entity types above
  • Field extraction (e.g. GET /api/v1/metadata/types/customProperties) resolves the MCP, AI-governance, audit-report and context-memory entity types instead of skipping them

Unit tests

  • I added unit tests for the new/changed logic.
  • File updated: openmetadata-service/src/test/java/org/openmetadata/service/util/SchemaFieldExtractorTest.java
    • extractFieldsSupportsMcpSchemas() — extracts fields for mcpServer / mcpExecution and asserts the resolved field types, following the existing extractFieldsSupportsLearningAndAiSchemas() test.
    • everyDiscoveredEntityTypeResolvesToAnExistingSchemaResource() — for every entity type returned by getAllEntityTypes(), resolves determineSchemaPath() and asserts the resource exists on the classpath, reporting entityType -> path for any that do not.

Verified in both directions on main:

# with the fix
Tests run: 13, Failures: 0, Errors: 0, Skipped: 0 -- SchemaFieldExtractorTest
BUILD SUCCESS

# with the six map entries reverted
AssertionFailedError: Entity types discovered under json/schema/entity/ whose schema path
does not exist. They are most likely missing from getEntitySubdirectory():
[contextMemory -> json/schema/entity/data/contextMemory.json,
 mcpServer -> json/schema/entity/data/mcpServer.json,
 mcpExecution -> json/schema/entity/data/mcpExecution.json,
 auditReport -> json/schema/entity/data/auditReport.json,
 aiGovernanceFramework -> json/schema/entity/data/aiGovernanceFramework.json,
 aiFrameworkControl -> json/schema/entity/data/aiFrameworkControl.json]

Backend integration tests

  • Not applicable (no backend API changes).

Ingestion integration tests

  • Not applicable (no ingestion changes).

Playwright (UI) tests

  • Not applicable (no UI changes).

Manual testing performed

  1. Observed the errors on a 1.13.1 deployment (Helm chart 1.13.1, Kubernetes 1.35) with default configuration and nothing MCP-related configured:
    ERROR o.o.s.u.SchemaFieldExtractor - Schema file not found at path: json/schema/entity/data/mcpServer.json
    ERROR o.o.s.u.SchemaFieldExtractor - Error processing entity type 'mcpServer': Schema file not found for entity type: mcpServer
    
  2. Confirmed against the published artifact that the resources ship under ai/, not data/:
    $ unzip -l openmetadata-spec-1.13.1.jar | grep 'entity/ai/mcp'
       31278  json/schema/entity/ai/mcpServer.json
       11771  json/schema/entity/ai/mcpExecution.json
    $ unzip -l openmetadata-spec-1.13.1.jar | grep -c 'entity/data/mcp'
    0
    
  3. Built the affected module: mvn -pl openmetadata-service -am -DskipTests install → BUILD SUCCESS
  4. Ran SchemaFieldExtractorTest with and without the source change (output above)

UI screen recording / screenshots:

Not applicable.

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR title is Fixes <issue-number>: <short explanation>
  • My PR is linked to a GitHub issue via Fixes #<issue-number> above.
  • I have commented on my code, particularly in hard-to-understand areas.
  • For JSON Schema changes: I updated the migration scripts or explained why it is not needed. (No schema changes — only the entity-type-to-subdirectory mapping used at load time.)
  • For UI changes: I attached a screen recording and/or screenshots above. (No UI changes.)
  • I have added tests (unit / integration / Playwright as applicable) and listed them above.
  • I have added a test that covers the exact scenario we are fixing.

Greptile Summary

This PR corrects schema-resource resolution for AI and context entities.

  • Maps five MCP/AI-governance entity types and auditReport to the ai schema directory.
  • Maps contextMemory to the context schema directory.
  • Adds extraction coverage for MCP schemas and verifies that every discovered entity type resolves to an existing classpath resource.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
openmetadata-service/src/main/java/org/openmetadata/service/util/SchemaFieldExtractor.java Adds the six missing entity-to-schema-subdirectory mappings.
openmetadata-service/src/test/java/org/openmetadata/service/util/SchemaFieldExtractorTest.java Adds MCP extraction assertions and comprehensive discovered-schema resource validation; the previously reported import-order issue is resolved.

Reviews (3): Last reviewed commit: "Merge branch 'main' into fix/schema-fiel..." | Re-trigger Greptile

…tories

getEntitySubdirectory() maps an entity type to the subdirectory that holds its
JSON schema and falls back to "data". Six entity types were missing from that
map, so their schemas were looked up under json/schema/entity/data/ and failed
to load. Each one logs an ERROR on every startup and is skipped by field
extraction:

  mcpServer, mcpExecution, aiGovernanceFramework, aiFrameworkControl,
  auditReport                    -> json/schema/entity/ai/
  contextMemory                  -> json/schema/entity/context/

Entity types are discovered by scanning json/schema/entity/ with ClassGraph in
getAllEntityTypes(), while loading goes through the hardcoded map, so the two
can drift. Besides adding the missing entries, this adds a test that walks every
discovered entity type and asserts its resolved schema path exists on the
classpath, so an entity added under a new subdirectory fails CI instead of
silently logging errors at runtime.
@jun-su-lee
jun-su-lee requested a review from a team as a code owner July 27, 2026 15:45
@github-actions

github-actions Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

✅ PR checks passed

The linked issue has a description and all required Shipping project fields set. Thanks!

@github-actions

Copy link
Copy Markdown
Contributor

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

google-java-format orders non-static imports lexicographically; the new
ArrayList import was placed after List, which fails mvn spotless:apply
in the java-checkstyle workflow.
@github-actions

Copy link
Copy Markdown
Contributor

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

@Vishnuujain Vishnuujain self-assigned this Jul 29, 2026
@Vishnuujain

Vishnuujain commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

@jun-su-lee Thanks for the detailed report and for digging up the four extra entity types on main that made this quick to confirm.

I've addressed it in #30618 with a broader fix: instead of adding entries to the map, it removes the map and resolves each schema's path from the classpath scan that already knows it. That also covers entity types shipped by downstream modules, which a map in this repo can't reach. Your guard test idea carried over.

Closing this one in favour of that. Appreciate you catching it

@gitar-bot

gitar-bot Bot commented Jul 29, 2026

Copy link
Copy Markdown
Code Review ✅ Approved

Maps missing AI and context entity types to their correct schema subdirectories in SchemaFieldExtractor and adds a test verifying all discovered entity types resolve to existing classpath resources. No issues found.

Options

Display: compact → Showing less information.

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

Compact
gitar display:verbose         

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

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.

mcpServer / mcpExecution missing from SchemaFieldExtractor subdirectory map — schema lookup resolves to entity/data/ and fails

2 participants