Skip to content

Honor latest on time-series listings without a time range; qualify the incident listing deletion scoping - #36594

Merged
TeddyCr merged 8 commits into
open-metadata:mainfrom
TeddyCr:fix/timeseries-latest-no-range
Oct 31, 2026
Merged

TeddyCr merged 8 commits into
open-metadata:mainfrom
TeddyCr:fix/timeseries-latest-no-range

Conversation

@TeddyCr

@TeddyCr TeddyCr commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

Describe your changes:

Fixes the incident listing 500s (testCaseEntityFQN unknown alias) and the WHERE deleted = FALSE failures that shared a root cause.

A time-series listing that passed latest=true without startTs/endTs routed to the plain revision listing, silently voiding the latest flag: every revision was paginated and the total counted revisions instead of partitions. The reshaped listings then exposed two latent SQL-shape bugs in the incident time-series code:

  • the no-range latest path ran the base partitioned queries, which bypassed the test_case join — the originEntityFQN predicate references the testCaseEntityFQN alias only that join introduces → unknown-alias SQL error;
  • the flat listing's deleted scoping only ever resolved because the test_case join happened to be in the same statement — deleted = FALSE dangled on a column the time-series table does not have.

Changes:

  • EntityTimeSeriesDAO: no-range partitioned listing and count (one row per entityFQNHash), routed by new latest-aware defaults (listWithOffset(filter, limit, offset, latest), listCount(filter, latest)); latest=false keeps the existing plain paths, so DAOs that override them (TestCaseResolutionStatusTimeSeriesDAO) and their callers of the plain path are unchanged.
  • EntityTimeSeriesRepository: the no-range branch passes latest through for both the rows and the total, the total counting partitions when latest=true.
  • TimeSeriesDAOs.TestCaseResolutionStatusTimeSeriesDAO: overrides the no-range latest listing/count to keep the origin join and the outer record-status filter (status/assignee/severity rank on each incident's latest record), exactly as the ranged templates do minus the BETWEEN.
  • incidentCondition: every incident listing carries its test-case deletion scoping as a qualified predicate — tc.deleted = FALSE/TRUE riding the test_case join, which is added only when the originEntityFQN predicate needs its alias; otherwise an indexed EXISTS on test_case instead, so no request pays a join no predicate needs and no clause dangles on a column the table lacks. include=all adds neither.
  • TestCaseResolutionStatusResource: include stays honored (default non-deleted, deleted, all all work — incidents of a soft-deleted test case remain listable under include=deleted/all); recorded in docs/decisions/2026-10-29-incident-listing-test-case-deletion-scoping-is-qualified.md.
  • ListFilter: a null Include is normalized to an explicit ALL in the constructor (before, "no deleted clause" was an accidental fall-through of an == chain), and getIncludeCondition is an exhaustive switch, so ALL's empty clause is a named decision a refactor cannot undo silently.

Type of change:

  • Bug fix
  • Improvement
  • New feature
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation

High-level design:

The repository no longer drops latest when there is no time range: the base DAO gains
partition-windowed (no-range) listing/count SQL and latest-aware defaults, and the incident DAO
re-shapes the no-range latest query the same way it shapes the ranged one (origin join + outer
record-status filter, minus the timestamp window). Deletion scoping for incidents becomes an
explicit, qualified property of the conditions instead of an accident of unqualified column-name
resolution, with the join paid only when a predicate needs it and an indexed EXISTS otherwise.
The contract decision (honored include, qualified scoping, the reindex consequence) is recorded
as ADR:2026-10-29-incident-listing-test-case-deletion-scoping-is-qualified.

Rejected alternative: normalizing timestamps to sentinels (0 / MAX) at the repository level —
that keeps the ranged queries serving the no-range case but changes BETWEEN semantics and
index behavior; the dedicated no-range queries keep the plain listing identical to before.

Tests:

Use cases covered

  • Incident listing (GET /v1/dataQuality/testCases/testCaseIncidentStatus) with latest=true and no time range: one record per incident, the chain's latest record, page total equal to the partition count — previously a 500 (testCaseEntityFQN alias) or a bogus column.
  • The outer record-status filter ranks on the incident's latest record (a New-only request does not match through an earlier record), for listing and count.
  • The base time-series listing (workflow-instance table) with latest=true and no time range: latest not voided; total counts partitions, not revisions.
  • include on the incident listing is honored: soft-deleted test cases' incidents are hidden by default and listed under include=deleted/all, consistent with incidentGroups.
  • The incident date-filter path (dateField + startTs/endTs, a stateId subquery on test_case_incident) rides the same condition path and is covered at DAO and REST level.
  • Every changed SQL shape executes against real MySQL and Postgres schemas (generated-column NOT NULL constraints included).

Unit tests

  • I added unit tests for the new/changed logic.
  • Files added/updated:
    • openmetadata-service/src/test/java/org/openmetadata/service/jdbi3/EntityTimeSeriesRepositoryLatestListTest.java (5 tests — repo routing/count branching; each mapping RED-checked by reverting the fix)
    • openmetadata-service/src/test/java/org/openmetadata/service/jdbi3/TestCaseResolutionStatusTimeSeriesDaoLatestTest.java (4 tests — no-range join/outer-filter routing, the qualified scope with join rider, the EXISTS-by-include routing without join; RED-checked)
    • openmetadata-service/src/test/java/org/openmetadata/service/jdbi3/TestCaseResolutionStatusRepositoryTest.java (the addOriginEntityFQNJoin tests rewritten against incidentCondition: join-rider scope, EXISTS-by-include, honored deleted/all)
    • openmetadata-service/src/test/java/org/openmetadata/service/jdbi3/ListFilterTest.java (2 tests — null include is an explicit ALL; no-arg default unchanged)
  • Coverage: the affected suites rerun green after every commit; the full openmetadata-service unit suite ran green; jacoco not run — the changed classes are covered by the listed suites.

Backend integration tests

  • I added integration tests in openmetadata-integration-tests/ for new/changed API endpoints.
  • Files added: openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/TestCaseResolutionStatusTimeSeriesListingIT.java (3 tests).

Runs on the final commit (b6c028ad):

  • Postgres: TestCaseResolutionStatusTimeSeriesListingIT 3/3, IncidentGroupsIT 65/65, IncidentPaginationIT 10/10, TestCaseLatestStatusIT 1/1 — all green.
  • MySQL (-DdatabaseType=mysql): TestCaseResolutionStatusTimeSeriesListingIT 3/3 green.
  • python3 .github/scripts/plan_local_java_tests.py --check-branch → "this branch leaves the map complete".

Ingestion integration tests

  • Not applicable (no ingestion changes).

Playwright (UI) tests

  • Not applicable (no UI changes).

Manual testing performed

  1. Reproduced the reported 500 (testCaseEntityFQN unknown alias) with the pre-fix code on -DdatabaseType=postgres from the incident listing count with originEntityFQN and no time range.
  2. Verified the fixed queries on both dialects via the IT; verified the tc.deleted probe (SELECT deleted FROM test_case) to distinguish scoping from a vanished row.

UI screen recording:

Not applicable — backend-only change (SQL/query routing + parameter semantics); no UI feature or behavior added.

Checklist:

  • I have read the CONTRIBUTING document.

  • My PR title is descriptive (no linked issue; carrying the skip-pr-checks label per author decision).

  • Not linked to a GitHub issue — per author decision this PR carries the skip-pr-checks label instead.

  • I have commented on my code, particularly in hard-to-understand areas.

  • For JSON Schema changes: not applicable (no schema changes).

  • For a UI feature or feature task: not applicable (no UI changes).

  • I have added tests (unit / integration / Playwright as applicable) and listed them above.

  • Self-review: reviewed the final diff against REVIEW.md via the pr-checklist process (three passes, every 🔴 fixed; pass 3 verified the final design with no 🔴 and its 🟡s either fixed (ADR scoping, keyset caveat) or deferred below; RED-checks recorded per fix→test mapping, including the include=deleted contract pinned against the interim hardcoded-scope design).

  • Decision check: docs/decisions/2026-10-29-incident-listing-test-case-deletion-scoping-is-qualified.md added in this PR.

  • I have added a test that covers the exact scenario we are fixing.

Known follow-ups deliberately out of scope here:

  • The no-range latest listing pages by LIMIT/OFFSET with no outer-level ORDER BY — the same gap the pre-existing ranged-latest twin already paginates with (derived-table order not guaranteed by the engine on later pages). One fix at the root would close all four partitioned shapes; changing those pre-existing shapes is left out of this bug fix.
  • The incident DAO's keyset/cursor readers (listAfterKeyset/listBeforeKeyset/getCursorAtOffset) build their conditions without the new shaping; none is wired to an incident listing today (documented in the ADR for whoever wires them).

🤖 Generated with Claude Code

Time-series listings that passed latest=true without startTs/endTs routed to
the plain revision listing, voiding the flag: every revision was paginated and
the total counted revisions instead of partitions. The base
EntityTimeSeriesDAO now has a no-range partitioned listing and count, and
TestCaseResolutionStatusTimeSeriesDAO overrides them to keep the origin
test_case join (the originEntityFQN predicate reads the testCaseEntityFQN
alias it introduces) and the outer record-status filter. ListFilter now
normalizes a null include to an explicit ALL so no consumer observes null,
and getIncludeCondition is an exhaustive switch.
…lude

The deleted scoping on the incident listing only ever resolved because the
test_case join happened to carry it; the reshaped listings must not depend on
an include clause riding an implicit join. addOriginEntityFQNJoin now joins
unconditionally and appends tc.deleted = FALSE — the same scoping the
incidentGroups summary SQL hardcodes — and the flat listing's include
parameter is deprecated (OpenAPI deprecated, RFC 9745 Deprecation header, server
warning when explicitly passed) per ADR:2026-10-29-incident-listing-include-deprecated.
The listing IT now also drives the endpoint over REST with latest and no time
range.
…otherwise

The unconditional join carried a cost every request paid. Keep the intent the
old condition aimed for, without its tautology: the join is added only when
originEntityFQN is present (its testCaseEntityFQN alias is the only thing the
join is for, with tc.deleted = FALSE riding it), and the always-on non-deleted
test-case scoping pays an indexed EXISTS instead when the join is not there.
ADR:2026-10-29-incident-listing-include-deprecated states the reindex
consequence: incident listings now also exclude soft-deleted test cases,
matching the search twin's default.
The incident DAO's keyset/cursor readers build their condition without the
join; they are unwired today, and the record now states what wiring them
requires instead of claiming they cannot dangle.
@TeddyCr TeddyCr added the skip-pr-checks Bypass PR metadata validation check label Oct 29, 2026
@TeddyCr
TeddyCr requested a review from a team as a code owner October 29, 2026 19:15
@TeddyCr
TeddyCr requested review from manerow and a balanced review from Copilot October 29, 2026 19:15

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 insufficient remaining quota.

@github-actions github-actions Bot added Ingestion safe to test Add this label to run secure Github workflows on PRs labels Oct 29, 2026
…ified

Scoping incidents to non-deleted test cases unconditionally made
include=deleted/all unrepresentable — incidents of a soft-deleted test case
were no longer listable. The include parameter is honored again, its scope
re-expressed as a tc-qualified predicate riding the join when the
originEntityFQN predicate needs it, or an indexed EXISTS when the join is not
needed — never the unqualified clause whose resolution depended on an implicit
join. ADR:2026-10-29-incident-listing-test-case-deletion-scoping-is-qualified
replaces the unshipped deprecation decision.
The listing IT now also seeds the test_case_incident row the date filters'
stateId subquery reads and asserts the dateField shapes at DAO level and over
REST; each contract assertion was red-checked against the hardcoded-scope
design it replaces.
Copilot AI balanced review requested due to automatic review settings October 29, 2026 20:10

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 insufficient remaining quota.

@github-actions github-actions Bot added safe to test Add this label to run secure Github workflows on PRs and removed safe to test Add this label to run secure Github workflows on PRs labels Oct 29, 2026
@TeddyCr TeddyCr changed the title Honor latest on time-series listings without a time range; fix incident listing SQL shaping; deprecate include on the flat incident listing Honor latest on time-series listings without a time range; qualify the incident listing deletion scoping Oct 29, 2026
Copilot AI balanced review requested due to automatic review settings October 29, 2026 20:52

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 insufficient remaining quota.

@github-actions github-actions Bot added safe to test Add this label to run secure Github workflows on PRs and removed safe to test Add this label to run secure Github workflows on PRs labels Oct 29, 2026
@TeddyCr
TeddyCr added this pull request to the merge queue Oct 29, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 30, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🚦 Removed from the merge queue — failed_checks (2026-10-30T09:19:08Z)

Blocked the queue: py-tests-status

@TeddyCr
TeddyCr added this pull request to the merge queue Oct 30, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 30, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🚦 Removed from the merge queue — failed_checks (2026-10-30T18:09:46Z)

Blocked the queue: playwright-summary

Failed Playwright tests:

  • Features/OntologyNativeAuthoring.spec.ts › a competing lease leaves no partial class and the form stays usable
  • Features/OntologyNativeAuthoring.spec.ts › creates every class field atomically, preserves free space, and cancels provisional relations
  • Features/OntologyNativeStudio.spec.ts › authors a native model through the shared View, Edit, and Query shell

Copilot AI balanced review requested due to automatic review settings October 30, 2026 22:49

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 insufficient remaining quota.

@github-actions github-actions Bot added safe to test Add this label to run secure Github workflows on PRs and removed safe to test Add this label to run secure Github workflows on PRs labels Oct 30, 2026
@gitar-bot

gitar-bot Bot commented Oct 30, 2026

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

🟡 Medium risk · Changing latest time-series queries and incident deletion filters could return incomplete or miscounted listings if partitioning or scoping is wrong.

Fixes latest=true on time-series listings without a time range, which previously routed to the plain revision listing and voided the flag, and scopes incident listings by test-case deletion via qualified predicates. Changes requested: the PR adds no decision record for the new time-series latest contract (one row per entityFQNHash partition, with paging.total counting partitions), and the Javadoc on TestCaseResolutionStatusRepository.listIncidentRecords still says latest is only honoured over a range. Deprecation warning on UI incident listings was resolved.

✅ 2 closed
✅ Quality: Deprecation WARN fires on every UI incident listing request

📄 openmetadata-service/src/main/java/org/openmetadata/service/resources/dqtests/TestCaseResolutionStatusResource.java:251-254
list() calls LOG.warn(INCLUDE_DEPRECATED) whenever the include query param is present. The UI's own DataQualityTab.tsx (EntitySummaryPanel, around line 394) still sends include: Include.NonDeleted with latest: true every time it fetches, and the PR leaves removing that for a later cleanup. Until that lands, every time someone opens that panel the server logs a WARN, which drowns out real warnings and makes the deprecation signal useless for spotting external callers. Either remove include from the UI call in this PR, or log at DEBUG (or rate-limit the warning) and leave the Deprecation header as the signal to clients.

Closed: Quality: No decision record for latest=true without a time range

📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EntityTimeSeriesDAO.java:165-179 📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EntityTimeSeriesDAO.java:418-432 📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EntityTimeSeriesRepository.java:244-249 📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EntityTimeSeriesRepository.java:279 📄 docs/decisions/2026-10-29-incident-listing-include-deprecated.md:1-15
This PR changes what the REST API returns for every time-series listing that inherits EntityTimeSeriesDAO, such as workflow instances and incidents. Before, latest=true with no startTs/endTs returned every revision, and paging.total counted revisions. Now it returns one row per entityFQNHash partition, and paging.total counts partitions. The description states this as a rule: "The no-range latest total counts partitions (one per entityFQNHash), not revisions", and "latest=false keeps the existing plain listing and count paths". The only record the PR adds, 2026-10-29-incident-listing-include-deprecated.md, covers the include deprecation, not this. Clients (UI, SDKs) have to agree with this contract, and the repo squash-merges, so the rule will be lost once the PR merges. The record should say: "On time-series listings, latest=true returns the most recent record per partition (entityFQNHash) whether or not a time range is given, and paging.total is the partition count." It could also note the ORDER BY pagination gap the PR defers. Also, the Javadoc on TestCaseResolutionStatusRepository.listIncidentRecords still says "latest is only honoured over a range", which this change makes wrong.

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

@sonarqubecloud

Copy link
Copy Markdown

@TeddyCr
TeddyCr merged commit 3b46123 into open-metadata:main Oct 31, 2026
65 checks passed
TeddyCr added a commit that referenced this pull request Nov 2, 2026
…fy the incident listing deletion scoping (backport 2.0 #36594) (#36872)
ShaileshParmar11 added a commit that referenced this pull request Nov 5, 2026
…ager (#36690)

* Fixes 34616: List every open incident and hide incidents of deleted test cases

- Latest incident listings keep the latest record of each incident (stateId) instead of each
  test case, so a group's drill-down, drawer and bulk actions match the group count when a test
  case holds two open incidents.
- The search listing scopes include on the embedded testCase.deleted, and a soft delete or
  restore of a test case or any parent updates that flag on the incident documents under it.
- The latest aggregation's scope filter carries the caller's include.

* Send the incident deleted flag synchronously and cover restore

- The testCase.deleted update goes through the same synchronous update as the soft-delete
  cascade, so a failure reaches the retry queue and a quick restore cannot race it.
- TestCaseSoftDeleteSearchIT restores the table and checks the incident returns.
- The decision record states that the classic search listing stays per test case.

* Note that a failed incident flag update needs a reindex

* Expect the incident DAO's latest listing to partition by stateId after #36594

* Index incidents under every ancestor a soft delete matches and reach the staged index

- TestCaseResolutionStatusIndex rebuilt the test case without its test suite and then read the
  suite from the rebuilt copy, so testSuite, database, databaseSchema and service were never
  written. The doc now carries them all (from the resolved table and the original suite
  reference), and the strict read strips them and certification.
- The incident testCase.deleted update goes through getWriteFanoutTargets, so a reindex's staged
  index gets it too.
- TestCaseSoftDeleteSearchIT soft-deletes and restores the basic test suite.

* Apply an incident status to the incident it names, not the test case's latest

A test case can hold more than one open incident, and the grouped view now
lists each of them, but a status write was keyed by test case alone: a bulk
change picked from an older incident updated the newer one. The create request
takes an optional stateId; the server applies the status to that incident, after
checking it belongs to the request's test case, and rejects one sent with New.
A status for an incident without its own task no longer moves the open task of
another incident. The grouped view's bulk actions and the reopen action send
the incident's stateId.

* Let a bulk severity change name a New incident

A severity change re-sends the incident's current status, now with its stateId,
so an incident still in New sent New plus a stateId, which the previous commit
rejected before the severity path ran. New is now rejected only when it names a
resolved incident, where it would start a new incident under the old stateId;
on an open incident it only restates the status.

* Keep one open incident per test case; declare each index's deleted field

A test case could hold two open incidents: a failing test reused only an
open incident task, so an open incident started through the status API got
a second chain, and POST /tasks could start one at any time. Refuse a new
incident task while the test case has another open incident, and let a
failure join an open incident that has no task. This replaces the
per-stateId listing and the stateId on status writes, which are reverted.

Each search index now declares the field that marks its documents deleted
on its EntityIndexCapability (incidents: testCase.deleted). Soft-delete
propagation and the search list include filter both read it, replacing the
incident-specific code in SearchRepository and SearchListFilter.

* Keep the deleted filter on time series that carry their own deleted flag

The include filter now reads the deleted field from the entity's index
capability. Time series registered with none, so agent and MCP executions,
whose schemas have a deleted field, lost their filter. Declare deleted for
any time series whose schema has it.

* Format IncidentTaskIntegrationIT

* Leave the one-open-incident rule out of this change

Review asked to ship without it until the workflow-based incident code is
checked for what it already enforces. Reverts the TaskRepository guard, the
getOrCreateIncident join and their ITs; the ADR keeps the deleted-flag
scoping only.
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 skip-pr-checks Bypass PR metadata validation check

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants