Skip to content

Fixes 31564: pass the extended config when formatting a single-value rule - #31565

Merged
pmbrull merged 1 commit into
mainfrom
fix/context-rule-filter-false-incomplete
Aug 15, 2026
Merged

pmbrull merged 1 commit into
mainfrom
fix/context-rule-filter-false-incomplete

Conversation

@pmbrull

@pmbrull pmbrull commented Aug 14, 2026 •

Copy link
Copy Markdown
Member

Fixes #31564

Problem

In Settings → Personas → <persona> → AI Context → Add Rule, a filter condition that is fully
filled in is rejected on save:

Finish or remove the unfinished condition before saving. An unfinished condition is ignored, which
would widen this rule to match everything.

Nothing is unfinished. The match preview in the same drawer resolves the filter and reports the right
count, and "View in Explore" returns the same assets. The rule just cannot be saved from the UI.

It hits any condition using a single-value operator (Is, Is not, Contains, Is null,
Between, …) on a normal field. Two cases escape: multiselect operators (Any in, Not any in),
and custom-property (extension.*) fields.

Root cause

elasticSearchFormat extends the incoming config once at the top and hands extendedConfig to every
branch — the group branch, and the multiselect half of the rule branch — except the single-value half,
which passed the raw config straight to buildEsRule.

buildEsRule resolves the field's widget through that config (getWidgetForFieldOp →
config.widgets[widget]). A raw config resolves no widget, so it returns undefined.

The difference is invisible while a whole tree is formatted, because a rule is then always reached
through its group and so always receives an extended config. It surfaces the moment
elasticSearchFormat is called on a rule node directly — which is exactly what hasUnfinishedRule
(added in #30716) does to decide whether a row was left unfinished. It saw undefined, concluded the
row constrained nothing, and blocked the save.

Same tree, same config, opposite answers before this change:

elasticSearchFormat(tree, config)
// {"bool":{"must":[{"term":{"service.displayName.keyword":"banking-bigquery"}}]}}

elasticSearchFormat(firstRuleOf(tree), config)
// undefined

hasUnfinishedRule(tree, config)
// true

Fix

Pass extendedConfig to buildEsRule in the single-value branch, matching what the multiselect
branch beside it and the group branch already do. Formatting a whole tree is unaffected — the config
reaching buildEsRule there was already extended.

Tests

QueryBuilderElasticsearchFormatUtils.test.js, four new cases. The existing hasUnfinishedRule
coverage all used extension.* fields, which return through buildExtensionQuery before the widget
is ever resolved, so it could not see this; the new cases use a plain select field and a real
QbUtils.loadTree/checkTree tree.

  • a rule builds the same clause whether reached through its group or on its own
  • an entered single-value condition is accepted (fails without the fix)
  • an entered multiselect condition is accepted (the path that already worked, pinned)
  • a single-value condition with no value entered is still reported — the Fixes 30715: reject bodiless clauses in persona AI context rule filters #30716 behaviour this must
    not regress
Tests: 22 passed, 22 total

Also green: QueryBuilder*, AdvancedSearch*, ContextRule*, PersonaAIContext*, Explore*,
CuratedAssets* — 487 tests. ESLint clean, no new warnings.


🤖 Generated with Claude Code

…rule

elasticSearchFormat extends the incoming config once and hands extendedConfig
to every branch except the single-value half of the rule branch, which passed
the raw config to buildEsRule. buildEsRule resolves the field's widget through
that config, so a raw one resolves no widget and returns undefined.

The difference is invisible while formatting a whole tree, because a rule is
then always reached through its group and so always gets an extended config.
It surfaces when elasticSearchFormat is called on a rule node directly, which
is what hasUnfinishedRule does: every completed condition looked like it built
no clause, and the persona AI context rule editor refused to save it as an
"unfinished condition".

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Copilot AI lite review requested due to automatic review settings August 14, 2026 19:40

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.

@github-actions

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically.

Maintainers can bypass this check by adding the skip-pr-checks label.

@github-actions github-actions Bot added Ingestion safe to test Add this label to run secure Github workflows on PRs labels Aug 14, 2026
@gitar-bot

gitar-bot Bot commented Aug 14, 2026

Copy link
Copy Markdown
Code Review ✅ Approved

Passes the extended configuration to buildEsRule in the single-value branch of the query builder formatter, fixing false incomplete rule validation errors on save. 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 👍 / 👎 | Powered by Gitar — free for open source

@github-actions

Copy link
Copy Markdown
Contributor

Jest test Coverage

UI tests summary

Lines Statements Branches Functions
Coverage: 66%
66.83% (79803/119404) 51.21% (48662/95016) 52.2% (14577/27923)

@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown
Contributor

🔴 Playwright Results — workflow failed

Validated commit d3e4bf72be5cdc850b0f249010f4b519b84e35e0 in Playwright run 31834330360, attempt 1.

✅ 550 passed · ❌ 0 failed · 🟡 0 flaky · ⏭️ 0 skipped · 🧰 0 lifecycle flaky

Pipeline and setup failures (1)

  • Playwright performance gate Maximum shard-job elapsed before upload failed (target ≤ 1800 s) — exceeded on 1 shard(s): chromium-01 1853 s.

Performance

Blocking targets: ❌ unmet · Optimization targets: 🟡 in progress

Shard-job maxima below are not the full workflow wall time; the linked run includes build, fixture, planning, and reporting.

🕒 Full workflow signal wall (to summary) 1h 0m 42s

⏱️ Max setup 2m 58s · max shard execution 18m 14s · max shard-job elapsed before upload 30m 53s · reporting 5s

🌐 214.51 requests/attempt · 2.83 app boots/UI scenario · 4.20% common-shard skew

Optimization targets still in progress:

  • Browser traffic was 214.51 requests per attempt (convergence target: fewer than 200).
  • Application boot ratio was 2.83 per UI scenario (1618 boots / 571 scenarios; convergence target: at most 1).
Shard Passed Failed Flaky Skipped Lifecycle failed Lifecycle flaky
✅ Shard chromium-01 138 0 0 0 0 0
✅ Shard chromium-02 131 0 0 0 0 0
✅ Shard chromium-03 130 0 0 0 0 0
✅ Shard data-asset-rules-01 61 0 0 0 0 0
✅ Shard domain-isolation-01 14 0 0 0 0 0
✅ Shard global-state-01 34 0 0 0 0 0
✅ Shard ingestion-01 1 0 0 0 0 0
✅ Shard reindex-01 2 0 0 0 0 0
✅ Shard search-01 10 0 0 0 0 0
✅ Shard search-rbac-01 29 0 0 0 0 0

📦 Download artifacts

How to debug locally
# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip    # view trace

@harshach harshach added the To release Will cherry-pick this PR into the release branch label Aug 14, 2026
@pmbrull
pmbrull merged commit a58ac44 into main Aug 15, 2026
153 of 156 checks passed
@pmbrull
pmbrull deleted the fix/context-rule-filter-false-incomplete branch August 15, 2026 11:11
pmbrull added a commit that referenced this pull request Aug 15, 2026
…rule (#31565)

elasticSearchFormat extends the incoming config once and hands extendedConfig
to every branch except the single-value half of the rule branch, which passed
the raw config to buildEsRule. buildEsRule resolves the field's widget through
that config, so a raw one resolves no widget and returns undefined.

The difference is invisible while formatting a whole tree, because a rule is
then always reached through its group and so always gets an extended config.
It surfaces when elasticSearchFormat is called on a rule node directly, which
is what hasUnfinishedRule does: every completed condition looked like it built
no clause, and the persona AI context rule editor refused to save it as an
"unfinished condition".

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
@pmbrull

pmbrull commented Aug 15, 2026

Copy link
Copy Markdown
Member Author

picked by hand to 2.0

@github-actions

Copy link
Copy Markdown
Contributor

Failed to cherry-pick changes to the 1.13 branch.
Please cherry-pick the changes manually.
You can find more details here.

@github-actions

Copy link
Copy Markdown
Contributor

Failed to cherry-pick changes to the 2.0 branch.
Please cherry-pick the changes manually.
You can find more details here.

anuj-kumary added a commit that referenced this pull request Aug 17, 2026
…31581)

* test(playwright): add E2E coverage for Persona AI Context rule builder

Adds 11 Playwright tests covering the full rule CRUD flow, filter
validation, and individual field behaviours for the AI Context tab in
Persona settings.

The most important addition is a regression test for #31564: before
PR #31565 a fully-completed single-value condition (e.g. Description
Contains "…") was incorrectly rejected with the "unfinished condition"
error because `elasticSearchFormat` passed raw `config` instead of
`extendedConfig` to `buildEsRule`, causing widget resolution to fail
and `hasUnfinishedRule` to return true.

Tests added:
- Rule CRUD serial group: empty state, create, edit, delete
- Filter validation serial group: incomplete condition blocks save,
  regression #31564 (Description Contains allows save), entity-type
  switch clears filter, duplicate name rejected
- Rule editor fields: max-assets clamping, toggle visibility,
  knowledge entity-type forces Fully rendered on

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* fix(playwright): fix regression test selector and add operator selection step

Live browser testing revealed two issues with the Persona AI Context
regression spec:

1. `page.locator('.rule').first()` finds the GROUP container which can
   be hidden in some builds — go directly to `.rule--field .ant-select`
   at page level instead.

2. The Description field uses `match_phrase` operators. The text widget
   (`.rule--widget--TEXT`) only renders after an operator is selected.
   Add an explicit "Contains" operator selection step so the input is
   available before we try to fill it.

Also: add `.first()` guard on the Fully rendered switch locator in the
knowledge-entity-type test (multiple elements can match) and add a note
that react-aria Switch stores state in the checked property, not
aria-checked.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* fix(playwright): address gitar-bot review findings in AI Context spec

Three issues raised in PR #31581 review:

1. `openAddRuleDrawer`: `isVisible({ timeout: 500 })` silently ignores
   the timeout and returns synchronously — replace with
   `emptyBtn.or(headerBtn).first().waitFor()` so we genuinely wait,
   then branch on `isVisible()` after the element is confirmed present.

2. `waitForTimeout(300)` sleeps after clicking add-context-condition are
   flaky: replaced with `page.locator('.rule--field .ant-select').first()
   .waitFor({ state: 'visible' })` at all three call sites.

3. Comment on the Fully rendered switch assertion said "use .isChecked()"
   but the code uses Playwright's `toBeChecked()` matcher — reworded to
   accurately describe why the property-based check is needed.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* refactor(playwright): merge CRUD serial tests into one test, remove serial from filter validation

CRUD tests (empty→create→edit→delete) are an inherently sequential
flow where edit and delete depend on state created by earlier steps.
Collapsing them into a single test with test.step() makes the
dependency explicit and atomic: a step failure aborts only that test
rather than silently skipping later ones via describe.serial.

Filter validation tests are each self-contained (each creates and
discards its own rule within a single test body), so describe.serial
was unnecessary. Removing it ensures a failure in the "incomplete
condition" test never prevents the regression test (#31564) from
running.

Also replace waitForTimeout(300) with waitFor({ state: 'visible' })
on the condition-row field selector to eliminate timing-based flakes.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* ci(playwright): add impact mapping for PersonaAIContextRules spec

Adds a mapping so changes to the PersonaAIContext component tree
(src/components/Settings/Persona/PersonaAIContext/**) or PersonaAPI.ts
on a future PR automatically include the three AI Context spec files
in the CI plan rather than falling through to an unmapped-file warning.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* ci(playwright): seed timing-baseline.json for PersonaAIContextRules spec

The plan-playwright gate hard-fails when a wholly-new spec file has
>= 5 tests with no timing history — the FALLBACK_TEST_MS reservation
(30s × 8 = 4 min) would under-budget the shard and risk a SIGTERM on
the merge queue (see PR #30812).

Add 8 entries using the real Playwright test IDs (obtained via
`playwright test --list`) and calibrated durations based on comparable
tests in PersonaAIContext.spec.ts and PersonaFlow.spec.ts. The nightly
full-mode run will replace these estimates with measured values via the
auto-refresh workflow once the spec first executes.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* fix(playwright): address gitar-bot/greptile PR comments for PersonaAIContextRules spec

- Wrap all tests in test.describe.serial: shared PersonaClass instance running
  under fullyParallel:true caused the CRUD "empty state" assertion to race against
  filter/editor tests concurrently creating rules on the same persona
- Move beforeAll/afterAll inside the serial describe using test.beforeAll/test.afterAll
  (not base.beforeAll), matching the pattern in PersonaAIContext.spec.ts
- Remove test.slow(true) from both hooks — Playwright throws "can only be called
  inside test" when used in beforeAll/afterAll
- Remove two redundant // Cleanup inline comments (greptile P2) that just restated
  the next line of code

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* ci(playwright): refresh PersonaAIContextRules test IDs in timing-baseline.json

The describe.serial wrapper added in the previous commit changed all 8
test-ID hashes for PersonaAIContextRules.spec.ts (test ID is computed
from the full describe-path, so wrapping the suite in an outer
describe.serial changes every hash). The plan-playwright gate hard-fails
when every test in a file >= 5 tests falls through to FALLBACK_TEST_MS
with no timing history.

Surgically replace the 8 stale IDs with the IDs from the current structure
obtained via `npx playwright test --list --reporter=json`. File and title
fields are unchanged; only the `"id"` values are updated.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* ci: retrigger plan-playwright after timing-baseline refresh

The previous CI run used a merge commit that predated the timing-baseline
ID refresh in 7fa030d. Force a new run against the updated merge commit.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* fix(plan-playwright): always include timing-baseline.json alongside history artifacts

The stale-baseline gate fires when all tests in a new spec file have no
timing history. Previously, timing-baseline.json was only used as a
fallback when NO history artifacts were downloaded from recent CI runs.
Once any artifact existed (typical for an active repo), the baseline was
skipped entirely — so seeding a new spec's durations into the baseline had
no effect and the gate would always fire for newly-added spec files.

Fix: unconditionally append --history timing-baseline.json so it is always
consulted alongside downloaded artifacts. When artifacts exist the baseline
acts as a supplemental seed for new specs not yet in any full-run artifact;
when no artifacts were downloaded it remains the sole source.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* Revert "fix(plan-playwright): always include timing-baseline.json alongside history artifacts"

This reverts commit 25613c8.

---------

Co-authored-by: Claude Sonnet 4.6 <[email protected]>
(cherry picked from commit 31cca94)
anuj-kumary added a commit to anuj-kumary/OpenMetadata that referenced this pull request Aug 17, 2026
…pen-metadata#31581)

* test(playwright): add E2E coverage for Persona AI Context rule builder

Adds 11 Playwright tests covering the full rule CRUD flow, filter
validation, and individual field behaviours for the AI Context tab in
Persona settings.

The most important addition is a regression test for open-metadata#31564: before
PR open-metadata#31565 a fully-completed single-value condition (e.g. Description
Contains "…") was incorrectly rejected with the "unfinished condition"
error because `elasticSearchFormat` passed raw `config` instead of
`extendedConfig` to `buildEsRule`, causing widget resolution to fail
and `hasUnfinishedRule` to return true.

Tests added:
- Rule CRUD serial group: empty state, create, edit, delete
- Filter validation serial group: incomplete condition blocks save,
  regression open-metadata#31564 (Description Contains allows save), entity-type
  switch clears filter, duplicate name rejected
- Rule editor fields: max-assets clamping, toggle visibility,
  knowledge entity-type forces Fully rendered on

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* fix(playwright): fix regression test selector and add operator selection step

Live browser testing revealed two issues with the Persona AI Context
regression spec:

1. `page.locator('.rule').first()` finds the GROUP container which can
   be hidden in some builds — go directly to `.rule--field .ant-select`
   at page level instead.

2. The Description field uses `match_phrase` operators. The text widget
   (`.rule--widget--TEXT`) only renders after an operator is selected.
   Add an explicit "Contains" operator selection step so the input is
   available before we try to fill it.

Also: add `.first()` guard on the Fully rendered switch locator in the
knowledge-entity-type test (multiple elements can match) and add a note
that react-aria Switch stores state in the checked property, not
aria-checked.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* fix(playwright): address gitar-bot review findings in AI Context spec

Three issues raised in PR open-metadata#31581 review:

1. `openAddRuleDrawer`: `isVisible({ timeout: 500 })` silently ignores
   the timeout and returns synchronously — replace with
   `emptyBtn.or(headerBtn).first().waitFor()` so we genuinely wait,
   then branch on `isVisible()` after the element is confirmed present.

2. `waitForTimeout(300)` sleeps after clicking add-context-condition are
   flaky: replaced with `page.locator('.rule--field .ant-select').first()
   .waitFor({ state: 'visible' })` at all three call sites.

3. Comment on the Fully rendered switch assertion said "use .isChecked()"
   but the code uses Playwright's `toBeChecked()` matcher — reworded to
   accurately describe why the property-based check is needed.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* refactor(playwright): merge CRUD serial tests into one test, remove serial from filter validation

CRUD tests (empty→create→edit→delete) are an inherently sequential
flow where edit and delete depend on state created by earlier steps.
Collapsing them into a single test with test.step() makes the
dependency explicit and atomic: a step failure aborts only that test
rather than silently skipping later ones via describe.serial.

Filter validation tests are each self-contained (each creates and
discards its own rule within a single test body), so describe.serial
was unnecessary. Removing it ensures a failure in the "incomplete
condition" test never prevents the regression test (open-metadata#31564) from
running.

Also replace waitForTimeout(300) with waitFor({ state: 'visible' })
on the condition-row field selector to eliminate timing-based flakes.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* ci(playwright): add impact mapping for PersonaAIContextRules spec

Adds a mapping so changes to the PersonaAIContext component tree
(src/components/Settings/Persona/PersonaAIContext/**) or PersonaAPI.ts
on a future PR automatically include the three AI Context spec files
in the CI plan rather than falling through to an unmapped-file warning.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* ci(playwright): seed timing-baseline.json for PersonaAIContextRules spec

The plan-playwright gate hard-fails when a wholly-new spec file has
>= 5 tests with no timing history — the FALLBACK_TEST_MS reservation
(30s × 8 = 4 min) would under-budget the shard and risk a SIGTERM on
the merge queue (see PR open-metadata#30812).

Add 8 entries using the real Playwright test IDs (obtained via
`playwright test --list`) and calibrated durations based on comparable
tests in PersonaAIContext.spec.ts and PersonaFlow.spec.ts. The nightly
full-mode run will replace these estimates with measured values via the
auto-refresh workflow once the spec first executes.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* fix(playwright): address gitar-bot/greptile PR comments for PersonaAIContextRules spec

- Wrap all tests in test.describe.serial: shared PersonaClass instance running
  under fullyParallel:true caused the CRUD "empty state" assertion to race against
  filter/editor tests concurrently creating rules on the same persona
- Move beforeAll/afterAll inside the serial describe using test.beforeAll/test.afterAll
  (not base.beforeAll), matching the pattern in PersonaAIContext.spec.ts
- Remove test.slow(true) from both hooks — Playwright throws "can only be called
  inside test" when used in beforeAll/afterAll
- Remove two redundant // Cleanup inline comments (greptile P2) that just restated
  the next line of code

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* ci(playwright): refresh PersonaAIContextRules test IDs in timing-baseline.json

The describe.serial wrapper added in the previous commit changed all 8
test-ID hashes for PersonaAIContextRules.spec.ts (test ID is computed
from the full describe-path, so wrapping the suite in an outer
describe.serial changes every hash). The plan-playwright gate hard-fails
when every test in a file >= 5 tests falls through to FALLBACK_TEST_MS
with no timing history.

Surgically replace the 8 stale IDs with the IDs from the current structure
obtained via `npx playwright test --list --reporter=json`. File and title
fields are unchanged; only the `"id"` values are updated.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* ci: retrigger plan-playwright after timing-baseline refresh

The previous CI run used a merge commit that predated the timing-baseline
ID refresh in 7fa030d. Force a new run against the updated merge commit.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* fix(plan-playwright): always include timing-baseline.json alongside history artifacts

The stale-baseline gate fires when all tests in a new spec file have no
timing history. Previously, timing-baseline.json was only used as a
fallback when NO history artifacts were downloaded from recent CI runs.
Once any artifact existed (typical for an active repo), the baseline was
skipped entirely — so seeding a new spec's durations into the baseline had
no effect and the gate would always fire for newly-added spec files.

Fix: unconditionally append --history timing-baseline.json so it is always
consulted alongside downloaded artifacts. When artifacts exist the baseline
acts as a supplemental seed for new specs not yet in any full-run artifact;
when no artifacts were downloaded it remains the sole source.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

* Revert "fix(plan-playwright): always include timing-baseline.json alongside history artifacts"

This reverts commit 25613c8.

---------

Co-authored-by: Claude Sonnet 4.6 <[email protected]>

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

Ingestion safe to test Add this label to run secure Github workflows on PRs To release Will cherry-pick this PR into the release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Persona AI Context: a completed filter condition is rejected as "unfinished" and the rule cannot be saved

3 participants