Repository navigation
Fixes 37882: Ontology Studio duplicate rules, per-ontology saved queries, Tooltip crash and nested buttons - #37883
Conversation
…ltip and nested buttons - A rule that states what a live rule of the same subject already states is refused (400) on every ontology write. Import preview marks a rule the file repeats as DUPLICATE, so it no longer passes preview and fails at apply. - Saved SPARQL queries carry an optional ontologyId, kept by the server, so Ontology Studio can list a query only in the ontology it was saved in. - Tooltip wires a disabled child through useFocusable instead of react-aria's <Focusable>, whose development-only check threw in the Tabs actions slot. - InboxIconButton and SubRail render TooltipTrigger as the button instead of nesting a <button> inside it.
✅ PR checks passedThe linked issue has a description and all required Shipping project fields set. Thanks! |
… check, record the decisions - rdfAPI keeps a saved query's ontologyId, so a save from the OSS console no longer unscopes Ontology Studio queries. - The duplicate-rule check reads LIMIT + 1 same-subject rules and refuses the write past the working model's 10,000 limit instead of missing a duplicate. - Regenerate settings.ts and sparqlQuerySettings.ts, which embed the saved-query type. - ADR:2026-11-16-a-live-rule-is-stated-once records both rules; the import record gains amendment v15 for duplicate rules.
The per-rule query re-read and re-signed every same-subject rule for each changed rule, which made a brick install take 1381 s instead of 143.5 s and exhausted the connection pool. The check now reads the live rules of 20 changed subjects per query and signs each once; brick installs in 181.6 s.
A batch of 20 subjects whose rules together pass the 10,000 working-model bound is halved until each part fits, so only a single subject with more than 10,000 live rules refuses the write. ADR:2026-11-16-a-live-rule-is-stated-once v2 records the batch size, the per-subject bound and the Brick timings.
harshach
left a comment
There was a problem hiding this comment.
The duplicate check is in the right place and the batching looks sound, but on MySQL the new axiomsOfSubjects read doesn't lock the way ancestors and disjointAxioms do, so two concurrent writers can still store the same rule. I'd like that read to use FOR UPDATE before this merges. I'd also like IT coverage for the change-set and PATCH paths the description promises, and a visible focus ring on the inbox and sub-rail buttons now that TooltipTrigger hides the outline. The rest are small test and ADR wording nits.
| @SqlQuery( | ||
| "SELECT a.json FROM ontology_axiom_entity a JOIN ontology_reference r " | ||
| + "ON r.sourceId = a.id AND r.ontologyId = a.ontologyId " | ||
| + "WHERE a.ontologyId = :ontologyId AND a.deleted = FALSE " | ||
| + "AND r.sourceType = 'ontologyAxiom' AND r.role = 'AXIOM_SUBJECT' AND r.iriHash IN (<iriHashes>) " | ||
| + "ORDER BY a.name, a.id LIMIT :limit") |
There was a problem hiding this comment.
On MySQL (REPEATABLE READ), two writers that each add the same rule serialize on the ontology state lock. The second writer's plain SELECT can still read from a snapshot taken before the first writer committed, so both pass and the duplicate is stored. Should this query take @Define("locking") String locking and run with FOR UPDATE like ancestors and disjointAxioms? Postgres READ COMMITTED isn't affected.
requireValid already builds its Context with forUpdate = true, and ADR 2026-10-14-ontology-definitions-have-independent-entity-storage asks for locking reads on both sides of the reference/axiom join for exactly this case.
There was a problem hiding this comment.
Yes, done in 67c5b01. axiomsOfSubjects now takes @Define("locking") and requireDistinctRules passes FOR UPDATE (the same constant the working-model Context uses when forUpdate is set). A second concurrent writer on MySQL now does a current read and sees the first writer's committed rule. Recorded as v3 of ADR:2026-11-16-a-live-rule-is-stated-once, citing the independent-entity-storage ADR.
| <TooltipTrigger | ||
| aria-label={t('label.inbox')} | ||
| className={classNames('ask-rail__item', { | ||
| 'ask-rail__item--active': isActive, | ||
| })} | ||
| data-testid="ai-inbox-icon-btn" |
There was a problem hiding this comment.
Now that TooltipTrigger is the button, keyboard focus on the inbox launcher has no visible indicator, because the trigger forces outline-hidden and .ask-rail__item defines no focus style. Could you add a :focus-visible (or [data-focus-visible]) ring to .ask-rail__item? That would also cover Rail, which shares the gap.
There was a problem hiding this comment.
Done in 67c5b01. .ask-rail__item draws outline: 2px solid var(--tw-border-color-brand); outline-offset: 2px on [data-focus-visible] and :focus-visible. It's unlayered LESS, so it wins over tw:outline-hidden, and the shared class covers Rail too. yarn token-audit reports no new errors.
| <TooltipTrigger | ||
| aria-label={item.label} | ||
| className={itemClassName} | ||
| data-testid={`ask-sub-rail-item-${item.key}`} | ||
| onPress={item.onClick}> |
There was a problem hiding this comment.
Nit: the action-only sub-rail button also loses its visible keyboard focus ring now that it is the TooltipTrigger. Whatever focus style goes onto .ask-rail__item should also go onto .ask-sub-rail__item.
There was a problem hiding this comment.
Done in 67c5b01. The same focus rule is on .ask-sub-rail__item.
| @Test | ||
| void aSecondRuleStatingTheSameThingIsRefused(TestNamespace ns) { |
There was a problem hiding this comment.
Could you add IT coverage for the two paths the description promises but no test exercises? (1) A change set with two identical new rules: assert 400 and that neither rule is stored. (2) A PATCH that changes an existing rule's expressions to match another live rule: assert it is refused.
There was a problem hiding this comment.
Added both in 67c5b01.
(1) aChangeSetWithTwoIdenticalRulesAppliesNeither: apply doesn't fail with a 400 here. Each operation is its own write, so the second rule fails, apply records the change set as APPLY_FAILED, and the first operation rolls back. That's the same contract NativeOntologyImportPreviewIT asserts for a duplicate concept. The test asserts APPLY_FAILED, statuses [ROLLED_BACK, FAILED], the "already states this" message on the failed operation, and that the ontology has no rules.
(2) editingARuleIntoAnotherLiveRuleIsRefused: a JSON PATCH replacing /expressions with the other rule's returns 400 naming 'Customer is a Party', and the patched rule keeps its original expression.
There was a problem hiding this comment.
Correction, fixed in beae4b2: you were right about the 400. A native change set is validated once, after every operation, so the duplicate refuses the whole apply with 400 "The rule 'CustomerIsParty' already states this" and the transaction rolls both rules back. It isn't recorded as APPLY_FAILED. The test now asserts the 400, the message, an unchanged working revision and no stored rules. My earlier reply described the glossary change-set path, not the native one.
| () -> service.create(axiomRequest(ontology).withName("CustomerIsPartyAgain"))); | ||
|
|
||
| assertEquals(400, refused.getStatusCode()); | ||
| assertTrue(refused.getMessage().contains("Customer is a Party"), refused.getMessage()); |
There was a problem hiding this comment.
Nit: this assertion passes even if duplicateRule names the new rule instead of the existing one, because axiomRequest gives both the display name "Customer is a Party". Give the second request a different displayName so the test pins which rule the message names.
| () -> service.create(axiomRequest(ontology).withName("CustomerIsPartyAgain"))); | |
| assertEquals(400, refused.getStatusCode()); | |
| assertTrue(refused.getMessage().contains("Customer is a Party"), refused.getMessage()); | |
| () -> service.create(axiomRequest(ontology).withName("CustomerIsPartyAgain").withDisplayName("Customer is a Party again"))); | |
| assertEquals(400, refused.getStatusCode()); | |
| assertTrue(refused.getMessage().contains("'Customer is a Party'"), refused.getMessage()); |
There was a problem hiding this comment.
Applied in 67c5b01. The second request is Customer is a Party again, and the test asserts the message contains 'Customer is a Party', so it pins the existing rule.
| List.of(), | ||
| List.of(subClassOf(child, parent), subClassOf(child, parent)))); | ||
|
|
||
| final var preview = importer.preview(source, emptySnapshot(root())); |
There was a problem hiding this comment.
Nit: consider a second case where the target already stores the rule and the file lists it twice. Expect ALREADY_EXISTS then DUPLICATE and zero axiom operations. That is the case the old count-based matching planned as NEW, which then failed at apply; this test runs against an empty snapshot, so it only reaches the in-file branch.
There was a problem hiding this comment.
Added in 67c5b01: aStoredRuleListedTwiceAlreadyExistsThenIsADuplicate. The target already stores A ⊑ B, the file lists it twice, and the preview gives ALREADY_EXISTS then DUPLICATE with zero axiom operations. I generalised the test's imported helper into applied(root, source) to build that snapshot.
| whose signature the file already stated is a `DUPLICATE` item and plans no operation; a rule whose | ||
| signature a stored rule already has is `ALREADY_EXISTS`. Applying refuses a second live rule with | ||
| the same subject, type and signature (ADR:2026-11-16-a-live-rule-is-stated-once), so planning one | ||
| would pass preview and then fail at apply. `NativeOntologyImportItemsTest` guards this behavior. |
There was a problem hiding this comment.
Nit: could you add NativeOntologyImportItemsTest to the Guard line? The amendment says that test guards v15, but the header doesn't list it.
There was a problem hiding this comment.
Done in 67c5b01. NativeOntologyImportItemsTest is on the Guard line.
… and PATCH ITs - axiomsOfSubjects reads FOR UPDATE, so on MySQL REPEATABLE READ a second concurrent writer sees a rule the first just committed. - .ask-rail__item and .ask-sub-rail__item draw a brand outline on keyboard focus now that TooltipTrigger hides the outline. - ITs: a change set with two identical rules applies neither; a PATCH that turns a rule into another live rule is refused; the create test pins the name of the existing rule. - Import test for a stored rule the file lists twice. - ADR v3 (locking read) and wording; the import ADR's Guard lists NativeOntologyImportItemsTest.
…h 400 A native change set is validated once after every operation, so the duplicate refuses the whole apply rather than recording APPLY_FAILED; the test now asserts the 400, an unchanged working revision and no stored rules.
Code Review ✅ Approved 🔴 High risk 3 closed / 3 findingsAdding duplicate-rule enforcement to all ontology writes changes stored-data integrity and could roll back imports or change sets containing repeated statements. Refuses duplicate ontology rules at write time, marks repeated import rules as DUPLICATE so preview matches apply, and lets saved SPARQL queries carry an optional ✅ 3 closed✅ Quality: Import duplicate handling contradicts Accepted import ADR
✅ Quality: New cross-repo
|
| Compact |
|
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source
#37883 stopped planning a rule that a pack states twice; fhir repeats 731, so its preview plans 15673 operations, not 16404.
… SAML adopt 500, cache markers, stale expectations) (#38013) * test(it): read MySQL lock waits from performance_schema in DataProductDeleteRaceIT On CI the innodb_trx statement text never matched the blocked statements, so each race step only ended when a request hit MySQL's 50s lock-wait timeout, and one step outlived the 60s wait. data_lock_waits joined to data_locks names the table each blocked transaction waits on, independent of the statement text. Locally the three races now take 1.7-3.8s on MySQL instead of about 50s. (cherry picked from commit 536e181) * fix(mcp): serve the MCP app state from memory so a database outage answers 503, not a hang McpAvailabilityFilter read the McpApplication entity on every /mcp request, before the bearer token is checked. Once the cached entry expired, a database outage made every MCP request block on that read for ~20s instead of reaching the auth path that answers 503 with Retry-After (CredentialDatabaseOutageIT). The state is now kept in memory and re-read through the entity cache every 2s in the background; a failed re-read keeps the last state. ADR v2 records it. * fix(sso): reload a concurrently created SAML user from the database When two first SAML logins race, the loser adopts the winner's account. Its reload read through the entity cache, where the loser's own earlier miss had left a not-found marker, so with Redis enabled the adopt failed and the login answered 500 (SsoSamlLoginIT.concurrentFirstLoginsCreateOneAccount). * fix(migration): clear the not-found marker of a repaired context file FQN ContextFileFqnRepair invalidated the entity caches but not the negative cache, so a lookup of the derived FQN made before the repair kept answering 404 for 30s with Redis enabled (ContextFileFqnRepairMigrationIT). * test(it): wait for the held OIDC token exchange before the next test OC-17 released a held token request without waiting for it; the late answer minted an ID token that overwrote the provider's last issued token while OC-01 was asserting on it. * test(it): expect the fhir preview count without duplicate rules #37883 stopped planning a rule that a pack states twice; fhir repeats 731, so its preview plans 15673 operations, not 16404. * test(it): let the metric approval run land before the re-ingest baseline The reviewer PATCH starts an approval run that writes In Review asynchronously; reading the baseline before it landed made the status comparison flaky.
Describe your changes:
Fixes #37882
Four of the five defects from #37882. The fifth (Studio offers
Date, which the server rejected asxsd:date) is handled by #37911, which accepts Date properties with anom:daterange; the Studio keeps offering Date. The saved-query scoping UI is in open-metadata/openmetadata-collate#8596. Merge this PR first: the Collate PR reads the new saved-queryontologyIdfield.The rule '<name>' already states this; a duplicate rule adds nothing. The check sits inOntologyWorkingModel.requireValid, which every ontology write goes through: REST, change-set apply, import and pack install. Rules compare byNativeOntologyDocument.signature, the normalized signature import already uses, not by name. A newOntologyReferenceDAO.axiomsOfSubjectsquery reads the live rules of up to 20 changed subjects at a time; each rule is signed once.DUPLICATE("Listed more than once in the file."), the way a repeated concept already is. It no longer passes preview and then fails at apply.savedSparqlQuerygains an optionalontologyId, andSavedSparqlQueryServicekeeps it. The OSS SPARQL console never sets it. The generated TS types are regenerated.useFocusablehook (the tab-order-excluded span already did this) instead of react-aria's<Focusable>. That component's development-only check calledgetComputedStyleon a node with no window inside theTabs.Listactionsslot, which threw. Elsewhere it logged "<Focusable>child must have an interactive ARIA role". The disabled span stays in the tab order;excludeTriggerFromTabOrderbehaves as before.InboxIconButtonandSubRailrenderTooltipTriggeras the button (aria-label,className,onPress), asRailalready does. This removes thevalidateDOMNesting: <button> inside <button>warning in AI mode.Type of change:
High-level design:
Every ontology write already funnels through
OntologyWorkingState.mutate→OntologyWorkingModel.requireValid, so the duplicate check sits there once rather than in each entry point. It runs only for a rule whose structure changed in this write, so duplicates stored before this change don't block unrelated edits. Within one change set, two identical new rules are both written before validation, so the second is refused and the whole apply rolls back.Saved queries are one JSON document per user, so the optional field needs no migration: a stored query without it reads as unscoped.
Alternative considered for duplicates: blocking only in the Studio UI. Rejected because the API, change sets and CSV
AXIOMrows would still store them.Tests:
Use cases covered
ontologyId; one without stays unscoped.ButtoninTabs.Listactionsrenders, with a focusable wrapper.Unit tests
NativeOntologyImportItemsTest#aRuleListedTwiceIsADuplicateAndAddsNoSecondOperation,SavedSparqlQueryServiceTest#keepsTheOntologyAQueryWasSavedIn,tooltip.test.tsx"renders a disabled child in the Tabs actions slot" (fails on the old Tooltip).InboxIconButton+Sidebarsuites pass (99/99).application/tag/*("should render a tooltip trigger when tooltip is passed"). They fail identically onmainwithout this change.Backend integration tests
IndependentOntologyAxiomIT#aSecondRuleStatingTheSameThingIsRefusedIndependentOntologyAxiomIT(24/24) andNativeOntologyImportPreviewITpass.NativeOntologyEveryPackInstallIT: in the first full run, 16 of 17 packs installed and re-installed with no changes, and none hit the duplicate refusal. Brick timed out at 1381 s because the first version of the check re-read every same-subject rule for each changed rule. The check now reads 20 changed subjects per query and signs each rule once (21662fd).main, 1381 s with the per-rule check, 181.6 s with the batched check. Each was a single-pack run on MySQL + Elasticsearch on a laptop.NativeOntologyEveryPackInstallIT17/17 pass in 824 s (brick 156.7 s, fhir 203.4 s), andIndependentOntologyAxiomIT15/15.ancestors/disjointAxiomsqueries.Ingestion integration tests
Playwright (UI) tests
Visual regression baselines
ask-rail__itemclasses, butTooltipTriggeraddstw:h-max tw:w-max tw:outline-hidden, the same as the existingRailbuttons. A baseline may still need a refresh if the merge queue flags one.UI recording
Not applicable: these are standalone bug fixes, not a UI feature.
Checklist:
Fixes <issue-number>: <short explanation>Fixes #<issue-number>above.REVIEW.mdviapr-checklist: not run.ADR:2026-11-16-a-live-rule-is-stated-oncerecords the duplicate-rule refusal and theontologyIdcontract;2026-10-19-native-ontology-imports-use-working-draftsgains amendment v15.🤖 Generated with Claude Code
Summary by Gitar
sidebar.lessrdfAPI.tspreservesontologyIdwhen normalizing saved queries on library savesThis will update automatically on new commits.


Confidence Score: 5/5
The PR appears safe to merge; the failing apply-test expectation is fixed.Summary
The PR refuses duplicate ontology rules, preserves saved queries' optional
ontologyId, and fixes disabled tooltips and nested sidebar buttons.Reviews (7) · Last reviewed commit: "Expect a native change set with two iden..." · Reviewed by Greptile