Skip to content

Fixes #36189: Keep the Ontology Studio UI build inside the UI's src folder - #36642

Merged
harshach merged 2 commits into
mainfrom
harshach/ontology-studio/08-collate-ui-import
Oct 30, 2026
Merged

harshach merged 2 commits into
mainfrom
harshach/ontology-studio/08-collate-ui-import

Conversation

@harshach

@harshach harshach commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

Describe your changes:

Fixes #36189

What broke. After #36190 landed, Collate's UI release build failed with one error (Collate run):

[UNRESOLVED_IMPORT] Error: Could not resolve '../../../../../../../../openmetadata-service/src/main/resources/json/data/settings/sparqlQuerySettings.json' in src/openmetadata-ui/src/components/OntologyExplorer/OntologyStudio.utils.ts

Why it broke. OntologyStudio.utils.ts imported the server's sparqlQuerySettings.json by a relative path that climbs out of the UI's src/ folder. Collate's copy-om-to-collate step copies only src/** from openmetadata-ui/src/main/resources/ui/ into collate-ui/src/main/resources/ui/src/openmetadata-ui/, and a separate step copies playwright/**. From there the same path names a file that does not exist. The same is true of any production import that leaves src/, including the UI folder's own package.json, public/ and vite/.

What changed.

  • OntologyStudio.constants.ts holds the UI's own copy of the three seed templates, typed as SavedSparqlQuery[]. isCanonicalGlossaryQueryTemplate compares against that copy with the same isEqual check, so the console hides exactly the templates it hid before.
  • OntologyStudio.constants.test.ts imports the server file and asserts with toStrictEqual that the copy equals its queryTemplates. toStrictEqual rejects an extra undefined-valued key, as lodash isEqual does. If someone edits a server seed and skips the UI copy, Jest fails.
  • uiImportBoundary.test.ts fails, naming the file and the specifier, when a production file under src/ has a relative specifier that resolves outside src/. It reads these forms:
    • in .ts, .tsx, .js and .jsx files, import ... from, side-effect import, export ... from, import('...') and require('...');
    • in .less and .css files, @import, @import (reference) and url(...).
  • Test files are exempt, because Collate's Jest ignores src/openmetadata-ui/* and its build never reaches a test. The exempt paths are *.test.*, *.spec.*, __mocks__/, __tests__/, src/test/ and src/setupTests.js.
  • The new decision record ADR:2026-10-30-production-ui-code-imports-only-from-the-ui-src-folder states the rule, the test-file exception and its cost. That cost is that shared data is copied into src/ and pinned by a test. The record also lists the forms the guard does not read: import.meta.glob, new URL(..., import.meta.url), a template-literal import() and require.resolve. The guard also matches inside comments and strings. No production file uses those forms to leave src/ today.
  • ADR:2026-10-26-native-query-console-hides-only-unchanged-bundled-templates gains a v2 amendment that cites the new record and names the pin test as a guard. Its Consequences note that a PR changing only sparqlQuerySettings.json does not trigger the UI Jest job, so the nightly run catches drift after merge.

Review. An independent review of 6eaa7a58225 returned FIX with two majors, and this head resolves both. The guard's boundary moved from the UI folder to src/, and the import rule got its own decision record. A second independent review passed 5598cd5fc5c with three minors. The PR title now names the src/ folder, which fixes the first. A follow-up PR fixes the other two after this one lands.

  • The guard and the new record's list of unread forms leave out relative Tailwind @source, @reference, @plugin and @config, and Less data-uri(). None of them leaves src/ today.
  • The new record and the query-console amendment credit playwright/** to the copy-om-to-collate step, but a separate Collate step copies it. The rule itself is unchanged.

Type of change:

  • Bug fix

High-level design:

N/A, small change.

Tests:

Use cases covered

  • Collate's release build resolves every import in the OpenMetadata UI. maven-collate-ci builds Collate's UI from this head.
  • A native-scope query console still hides only unchanged bundled templates.

Unit tests

  • I added unit tests for the new/changed logic.
  • On Fixes 36189: Complete the native Ontology Studio shell and scoped queries #36190's tree, uiImportBoundary.test.ts fails and names src/components/OntologyExplorer/OntologyStudio.utils.ts. At this head it passes, reading 299 style files with 232 relative style specifiers, all inside src/.
  • The guard fails on each of these temporary production edits, restored afterwards: an import of ../../../package.json, an import from public/, a Less @import and @import (reference) that leave src/, a Less url('...') and a CSS unquoted url(...) that leave src/.
  • OntologyStudio.constants.test.ts fails when a copy entry gains description: undefined, and when the copy's savedAt changes.
  • Jest on the pin test, the guard, OntologyStudio.utils.test.ts, OntologyStudioQueryConsole.test.tsx and OntologyExplorerPage.test.tsx: 5 suites, 106 of 106 tests pass.

Backend integration tests

  • Not applicable (no backend API changes).

Playwright (UI) tests

  • Not applicable (no UI behavior changes).

UI screen recording:

Not applicable. This is a build fix with no visible change.

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.
  • I have added tests (unit / integration / Playwright as applicable) and listed them above.
  • Decision check: the new record and the amended record land in this PR.
  • I have added a test that covers the exact scenario we are fixing.

🤖 Generated with Claude Code

OntologyStudio.utils.ts imported sparqlQuerySettings.json from
openmetadata-service by an 8-level relative path. Collate builds this UI
from collate-ui/src/main/resources/ui/src/openmetadata-ui/, where that
path resolves to nothing, so its release build failed.

The UI now keeps its own copy of the three seed query templates in
OntologyStudio.constants.ts. A Jest test pins the copy to the server
file, and a second test fails when any production UI file imports a
relative path that leaves openmetadata-ui/src/main/resources/ui/. The
decision record gains a v2 amendment.
@harshach
harshach requested a review from a team as a code owner October 30, 2026 05:30
@harshach harshach added the safe to test Add this label to run secure Github workflows on PRs label Oct 30, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Jest test Coverage

UI tests summary

Lines Statements Branches Functions
Coverage: 80%
80.5% (134797/167435) 67.35% (48206/71569) 70.39% (27145/38562)

Collate's copy-om-to-collate step copies only src/** and playwright/**
from the UI folder, so a production import of package.json, public/ or
vite/ breaks Collate's build the same way the server import did. The
guard now compares each relative specifier against src/, and it also
reads .less and .css files for @import, @import (reference) and url().

Add ADR:2026-10-30-production-ui-code-imports-only-from-the-ui-src-folder
for the rule, its test-file exception, its cost and the forms the guard
does not read. The query-console record cites it, notes that a
server-only seed edit is caught by the nightly Jest run, and uses the
README's revision separator.

The pin test uses toStrictEqual, matching the console's lodash isEqual.
@gitar-bot

gitar-bot Bot commented Oct 30, 2026

Copy link
Copy Markdown
Code Review ✅ Approved

🟡 Medium risk · Replacing the server seed import with a UI copy could leave the console hiding stale templates if the copy drifts, despite its pin test.

Moves the Ontology Studio seed templates into the UI's own OntologyStudio.constants.ts and adds a boundary test so production imports stay inside the UI folder, fixing the Collate release build's unresolved sparqlQuerySettings.json import. No issues found.

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Display: compact → Showing compact verification results.

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

@harshach harshach changed the title Fixes #36189: Keep the Ontology Studio UI build inside the UI folder Fixes #36189: Keep the Ontology Studio UI build inside the UI's src folder Oct 30, 2026
@sonarqubecloud

Copy link
Copy Markdown

@harshach
harshach merged commit eeee22d into main Oct 30, 2026
73 checks passed
@harshach
harshach deleted the harshach/ontology-studio/08-collate-ui-import branch October 30, 2026 06:34
manerow pushed a commit that referenced this pull request Oct 30, 2026
…older (#36642)

* Fixes #36189: Keep the Ontology Studio UI build inside the UI folder

OntologyStudio.utils.ts imported sparqlQuerySettings.json from
openmetadata-service by an 8-level relative path. Collate builds this UI
from collate-ui/src/main/resources/ui/src/openmetadata-ui/, where that
path resolves to nothing, so its release build failed.

The UI now keeps its own copy of the three seed query templates in
OntologyStudio.constants.ts. A Jest test pins the copy to the server
file, and a second test fails when any production UI file imports a
relative path that leaves openmetadata-ui/src/main/resources/ui/. The
decision record gains a v2 amendment.

* Keep production UI imports inside the UI's src folder

Collate's copy-om-to-collate step copies only src/** and playwright/**
from the UI folder, so a production import of package.json, public/ or
vite/ breaks Collate's build the same way the server import did. The
guard now compares each relative specifier against src/, and it also
reads .less and .css files for @import, @import (reference) and url().

Add ADR:2026-10-30-production-ui-code-imports-only-from-the-ui-src-folder
for the rule, its test-file exception, its cost and the forms the guard
does not read. The query-console record cites it, notes that a
server-only seed edit is caught by the nightly Jest run, and uses the
README's revision separator.

The pin test uses toStrictEqual, matching the console's lodash isEqual.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend 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.

Ontology Studio: finish the native shell, tree and scoped Query experience

2 participants