Skip to content

Run a single test case on demand from the test case details page - #33499

Merged
ShaileshParmar11 merged 22 commits into
mainfrom
feat/tcd-2-run-test-case
Sep 22, 2026
Merged

ShaileshParmar11 merged 22 commits into
mainfrom
feat/tcd-2-run-test-case

Conversation

@ShaileshParmar11

@ShaileshParmar11 ShaileshParmar11 commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Describe your changes:

Fixes open-metadata/openmetadata-collate#6108

TCD-2, part of epic open-metadata/openmetadata-collate#6074.

Cross-repo link form is deliberate: the tracking issue lives in the Collate repo, and a bare #6108 here would autolink an unrelated issue in this repo.

Screen.Recording.2026-09-17.at.5.38.16.PM.mov

I added Run now to the test case details page. Until now, the only way to rerun one failing test was to trigger the suite's pipeline, which runs every test in the suite.

It is backed by a generic endpoint, POST /v1/services/ingestionPipelines/run, which runs a pipeline of type T scoped to entity E. The test case page is the first caller; "profile this table now" and "re-ingest this table" are then a button and a translation key, with no server change.

This design is the result of @TeddyCr's review. The first cut was a test-case-specific endpoint that scoped a mutated copy of the pipeline and returned 409 while a run was in progress. All three of his points are implemented: the per-run scope is now an explicit argument, the in-progress guard is gone, and the mechanism is generic.

Type of change:

  • New feature

High-level design:

One endpoint, one spine — EntityPipelineRunner, behind POST /v1/services/ingestionPipelines/run with the typed body {entityLink, pipelineType} (JSON Schema runIngestionPipelineForEntity.json). entityLink is OM's existing addressing, so <#E::testCase::fqn> and <#E::table::fqn> both work.

  1. Parse the link and pick a RunnablePipelineResolver by entity type. An unregistered pairing (a profiler for a test case, usage or lineage for a table) or a link to a field returns 400.
  2. Pick the lowest-id pipeline that is enabled and deployed among those the entity owns, the same rule as the pipeline's own Run action, so a client listing them checks permission and run state on the one a run will use. None → 404.
  3. Authorize ViewBasic on the target entity — a caller who may not see a test case or table may not aim a pipeline at it — then Trigger on that pipeline, plus the same limits as /trigger. Running one entity can never get around a policy that withholds either.
  4. Build the scope with a SourceConfigScoper keyed by pipeline type, resolve secrets, and run.
Axis Keyed by Implementations
RunnablePipelineResolver entity type testCase → its test suite; table → its database service
SourceConfigScoper PipelineType testSuite → testCases: [name]; profiler and autoClassification → a shared TableFilterScoper; metadata → that plus the mark-deleted switches

The scope travels as RunOptions, not as a mutated entity. RunOptions(sourceConfigOverride, appConfigOverride) is an explicit argument to PipelineServiceClientInterface.runPipelineWithOptions. The interface default applies the override onto a copy of the source config and runs it — that is what K8s, Argo and the hybrid runner get for free. Airflow is the only client that overrides it, because it is the only one whose DAG config is baked at deploy time, so the trigger conf is its one per-run channel. Consequences:

  • buildRunConf just serialises what it was handed; no test-suite knowledge in a generic transport.
  • The stored pipeline is never narrowed, so later scheduled runs are unaffected.
  • The ordering hazard is gone by construction rather than by comment: because the scope isn't on the entity, resolving secrets can't drop it for a caller without ViewAll.

Two traps the scopers close, written once instead of per feature:

  • markDeletedTables and friends default to true. A metadata run scoped to one table sees exactly one table, so without switching all four off it would soft-delete every other table in the service. The metadata scoper forces them false.
  • An incremental metadata pipeline starts each run from its last successful one. A scoped run that succeeded would move that point, and the next scheduled run would skip changes to every other table. The metadata scoper rejects scoped runs on incremental pipelines with a 400 rather than guess.

Airflow (openmetadata-managed-apis)

  • CustomPythonOperator applies sourceConfigOverride from the trigger conf for every DAG type, validating the merged config through the source config union.
  • A server-generated pipelineRunId travels in the conf, so the queued status the server records is the run the worker reports on, and a DAG-level on_failure_callback closes out a task killed before it starts.

UI — RunTestCaseButton (test case page only, as agreed in review)

  • Hidden without Trigger on the suite pipeline, and on the version page.
  • Disabled with the reason only when there is nothing to trigger: no pipeline linked, or the pipeline isn't deployed.
  • Stays enabled while a run is in progress, showing Queued/Running and a tooltip saying another run will start. Whether the in-flight run is the right one is the user's call: it may belong to another suite's pipeline, be stuck, or predate the change they are re-checking.
  • Polls every 5s and refreshes the test case when the run finishes.

Two bugs found by end-to-end testing, fixed here

  • A deployed source config with few fields set parsed as the messaging variant, which rejects database filters, so scoped auto-classification runs failed. The merged config is now settled through the union with empty fields excluded.
  • Airflow's trigger_dag zeroes the microseconds of logical_date, and a run is unique per (dag_id, logical_date), so a second trigger of the same pipeline within one second failed. This also affected /trigger on main. Keeping the true timestamp exposed a second, older bug: delete_dag_id never deleted task instances, and a task instance pins its dag version with a RESTRICT foreign key, so on Airflow 3 deleting a DAG that had ever executed was refused by the database. It now uses Airflow's own delete_dag.

Alternatives rejected

  • Running the whole suite: surprising from a button on one test case, and slow on large suites.
  • Deploying a one-off DAG per run: heavyweight, and it leaves DAGs behind to clean up.
  • Blocking a second run: the guard was keyed on the pipeline while the contended resource is the test case, which can sit in several suites with independently scheduled pipelines. It could not hold, and /trigger never had it.

Rollout: the server and openmetadata-managed-apis must be upgraded together. An older managed-apis ignores sourceConfigOverride (the run executes the whole suite or service) and pipelineRunId (the queued status never moves).

Tests:

Use cases covered

  • Admin runs one test case: only that test case gets a new result, and the button goes Queued → Run now with no reload.
  • A normal pipeline trigger still runs every test case in the suite, with no scope in the conf.
  • A second run while one is queued or running is accepted, and the button explains that it starts another.
  • No pipeline, or only a disabled or undeployed one: 404, and the button is disabled with the reason.
  • A data consumer can't run it and doesn't see the button; a data steward can; a data consumer who owns the pipeline sees it.
  • Scoped metadata, profiler and auto-classification runs touch only the target table, and an incremental metadata pipeline is rejected.
  • A caller with Trigger but without ViewAll still gets a correctly scoped run; one who cannot view the target entity at all is refused.

Unit tests

  • I added unit tests for the new/changed logic.
  • Java
    • RunOptionsTest (6): the override replaces top-level keys, an empty one returns the same pipeline, the source stays untouched.
    • SourceConfigScopersTest (7): the test case scope, exact regex-escaped table filters, the four mark-deleted switches, the incremental rejection.
    • RunnablePipelineSelectionTest (3): lowest id among enabled and deployed.
    • AirflowRESTClientTest (23): the conf carries the scope; a persisted subset is not re-sent.
    • K8sPipelineClientTest: the K8s job is scoped through the shared default method.
    • MeteredPipelineServiceClientTest: the metered client delegates runPipelineWithOptions.
  • Python
    • test_source_config_override.py (6): the override settles which config variant a sparse deployed one is — fails on the pre-fix code.
    • test_pipeline_run_id.py (8): run id adoption and the DAG failure callback.
    • test_trigger.py (1): runs triggered in the same second keep distinct logical dates.
    • test_operation_diagnostics.py: updated for the new deletion path.
    • ingestion/tests/unit/observability/data_quality/source/test_test_suite.py: a test case given by FQN selects nothing, so the scope uses the name.
    • Locally the whole openmetadata-airflow-apis suite passes: 45 tests, unit and integration, against Airflow 3.3.1.
  • Jest — RunTestCaseButton.test.tsx (8) and RunTestCaseButton.utils.test.ts (19): 98.33% lines on RunTestCaseButton.tsx, 100% on RunTestCaseButton.utils.ts.

Backend integration tests

  • I added integration tests in openmetadata-integration-tests/ for new/changed API endpoints.
  • RunIngestionPipelineForEntityIT (15), run against a real K3s cluster so the K8s client path executes:
    • 404: unknown test case; no pipeline; only undeployed; only disabled; a table with no profiler pipeline.
    • The scope is not persisted, for a test case and for a table.
    • The deployed pipeline is picked beside an undeployed one.
    • Trigger permission on the pipeline is required, and view permission on the target entity; a data steward without EditTests can run.
    • A run is accepted while the suite pipeline is running.
    • 400: profiler for a test case, usage, lineage, a test suite for a table, a link to a column, and an incremental metadata pipeline.
  • IngestionPipelineResourceIT (74) still passes alongside it.

Ingestion integration tests

  • Not applicable. The ingestion source's test-case filter is unchanged; only unit cases were added.

Playwright (UI) tests

  • I added Playwright E2E tests under openmetadata-ui/.../ui/playwright/.
  • playwright/e2e/Features/DataQuality/RunTestCase.spec.ts — 8 passing: disabled with "No pipeline linked"; disabled with "Pipeline is not deployed"; Run now queues a run and the button stays enabled with the in-progress tooltip; hidden from a data consumer; shown to a data consumer who owns the pipeline.

Manual testing performed

Local Docker stack with real Airflow 3.3.1, this branch's server jars and managed-apis, against a SQLite service with two tables and two test cases:

  1. Scoped test case run: the conf carried {pipelineRunId, sourceConfigOverride: {testCases: [name]}}, the run succeeded under that id, only that test case got a new result, and the stored pipeline was unchanged.
  2. Plain trigger of the same pipeline: no scope in the conf, both test cases ran.
  3. Concurrent runs: two runs fired in the same second were both accepted (before the logical_date fix, the second returned 400).
  4. Scoped metadata run: the target table was re-ingested and the other table was left alone. A control run with the same filters but mark-deleted left on did soft-delete it, which is the trap the scoper closes.
  5. Scoped profiler and auto-classification: only the target table got a new profile / sample data.
  6. Restricted caller: a bot with Trigger and ViewBasic but not ViewAll still got a correctly scoped run.
  7. Rejections: usage, lineage, a column link and an incremental metadata pipeline all returned 400; a table with no profiler pipeline returned 404.
  8. UI walkthrough: ready → queued toast → in-progress tooltip → second run accepted → results refreshed; plus the two disabled states and the hidden-for-data-consumer case.

UI screen recording / screenshots:

The recording above predates the review changes — it shows the button being blocked while a run is in progress, which is no longer the behaviour. TODO: re-record against the current build.

Checklist:

  • I have read the CONTRIBUTING document.

  • My PR title is Fixes <issue-number>: <short explanation> (the issue lives in the Collate repo; see the linking note above)

  • 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: runIngestionPipelineForEntity.json is a new request body only — no stored entity changed, so no migration is needed.

  • For UI changes: I attached a screen recording and/or screenshots above.

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

  • The issue properly describes why the new feature is needed, what's the goal, and how we are building it. Any discussion or decision-making process is reflected in the issue.

  • I have updated the documentation.

  • I have added tests around the new logic.

🤖 Generated with Claude Code

RetriggerConfidence Score: 5/5

The PR appears safe to merge; no outstanding correctness, security, or repository-rule issue remains.

Summary

This PR adds an entity-scoped ingestion-pipeline runner and exposes it through a “Run now” action on test-case details.

  • Resolves and authorizes the target entity and selected runnable pipeline independently.
  • Applies per-run source configuration through RunOptions without persisting narrowed pipeline configuration.
  • Supports Airflow, Kubernetes, Argo, hybrid, and metered clients, including server-generated run IDs and same-second Airflow triggers.
  • Adds safeguards for scoped metadata runs, including disabled deletion markers and rejection of incremental pipelines.
  • Adds backend, Python, UI unit, integration, and Playwright coverage.
Diagram
sequenceDiagram
    actor User
    participant UI as Test-case details
    participant API as POST /ingestionPipelines/run
    participant Runner as EntityPipelineRunner
    participant Repo as Pipeline repository
    participant Orchestrator as Airflow/K8s/Argo
    participant Worker as Ingestion workflow

    User->>UI: Click Run now
    UI->>API: entityLink + TEST_SUITE
    API->>Runner: Resolve target and pipeline
    Runner->>Runner: Authorize ViewBasic on target
    Runner->>Runner: Authorize Trigger on pipeline
    Runner->>Runner: Build per-run source override
    Runner->>Repo: Run pipeline with RunOptions
    Repo->>Orchestrator: Trigger with run ID and override
    Orchestrator->>Worker: Execute scoped workflow
    Worker-->>Repo: Report status under server run ID
    UI->>Repo: Poll pipeline status
    UI->>UI: Refresh test-case result when finished
Loading

Reviews (15) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..."

ShaileshParmar11 and others added 2 commits September 16, 2026 20:10
- POST /v1/dataQuality/testCases/{id}/run triggers the test suite's first
  enabled, deployed ingestion pipeline, scoped to that one test case. It is
  authorized like the pipeline's own trigger (Trigger on the pipeline) and
  rejected with 409 while a run of that pipeline is queued or running; runs
  that outlived their timeout do not count. The scope is applied to a copy,
  so scheduled runs keep running the whole suite.
- Airflow bakes a DAG's config at deploy time, so the per-run test case scope
  and a server-generated run id travel in the trigger conf. The task adopts
  that run id, so the queued status the server records is the one the worker
  (and the failure callback) updates.
- The pipeline decrypt/nullify logic moves to IngestionPipelineSecrets so the
  new endpoint and the ingestion pipeline resource share it.
- UI: a Run now button in the test case header, disabled with the reason when
  the suite has no runnable pipeline, the user lacks Trigger, or a run is in
  progress; it shows Queued/Running and polls until the run finishes.

Co-Authored-By: Claude Opus 5 <[email protected]>
…d to end

- Keep a run's test case scope for callers who may trigger the suite
  pipeline but not view it. Resolving the pipeline's secrets withholds its
  source config from such a caller, and the scope was set before that, so it
  was dropped and the whole suite ran. The scope is now applied last.
- Airflow: a DAG-level failure callback reports the failure under the run id
  from the trigger conf. A task killed before it starts never runs its own
  callback, so an on-demand run stayed queued - and blocked further runs -
  until the queued timeout.
- UI: Run now is primary with a Play icon and hidden from users who may not
  trigger the suite pipeline. The run state, label and disabled reason move
  to RunTestCaseButton.utils.
- Tests:
  - TestCaseRunIT: disabled-only suite is 404, a deployed pipeline is picked
    beside an undeployed one, a queued run is 409, and a running run blocks
    within the default timeout but not past the pipeline's workflowTimeout.
  - TestCaseRunScopeTest: the scope survives withheld source config.
  - Python: DAG failure callback; the test suite source matches test cases
    by name, not FQN, which the endpoint relies on.
  - Jest: component tests for visibility, click, error and queued state.
  - Playwright: disabled reasons, queuing a run, hidden from a data
    consumer, shown to a data consumer who owns the pipeline.

Co-Authored-By: Claude Opus 5 <[email protected]>
@github-actions github-actions Bot added safe to test Add this label to run secure Github workflows on PRs UI UI specific issues labels Sep 17, 2026
@ShaileshParmar11
ShaileshParmar11 marked this pull request as ready for review September 17, 2026 11:57
@ShaileshParmar11
ShaileshParmar11 requested review from harshsoni2024 and a lite review from Copilot September 17, 2026 11:57

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:

  • No GitHub issue is linked. Link an issue in the Development section of the PR (or add Fixes #12345 to the description). For a same-org cross-repo issue, add Fixes open-metadata/<repo>#123 to the description.

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

Copy link
Copy Markdown
Contributor

🔄 Playwright impact map auto-refreshed

This PR touched specs or UI source that changed the source→spec routing map. I regenerated .github/playwright/impact-map.generated.json and pushed the diff to this branch.

- source entries: 775 → 775
- 0 added, 0 removed, 7 changed spec-list

Entries whose spec list changed:
  openmetadata-ui/src/main/resources/ui/playwright/e2e/Utils/appMode.ts
  openmetadata-ui/src/main/resources/ui/playwright/e2e/fixtures/pages.ts
  openmetadata-ui/src/main/resources/ui/playwright/support/entity/TableClass.ts
  openmetadata-ui/src/main/resources/ui/playwright/utils/admin.ts
  openmetadata-ui/src/main/resources/ui/playwright/utils/common.ts
  openmetadata-ui/src/main/resources/ui/playwright/utils/testCases.ts
  openmetadata-ui/src/main/resources/ui/src/generated/entity/data/table.ts

What is this file? It is the auto-generated half of Playwright's PR planner. It routes "if source X changes, run specs Y" by walking spec imports and cross-referencing getByTestId strings. Hand-authored routing in impact-map.json always wins on conflict.

What if I want to regenerate locally instead? Run this before pushing your next change to skip the bot commit:

python3 .github/scripts/generate_playwright_impact_map.py
git add .github/playwright/impact-map.generated.json
git commit --amend --no-edit  # or a separate commit

Copilot AI review requested due to automatic review settings September 17, 2026 11:57

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

github-actions Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Jest test Coverage

UI tests summary

Lines Statements Branches Functions
Coverage: 72%
72.46% (103611/142986) 57.55% (63056/109553) 58.62% (20650/35223)

… same pipeline in UI and API

- Two concurrent run requests could both pass the in-progress check before
  either recorded its queued status, starting duplicate runs. The check and
  trigger now hold a per-pipeline lock until the queued status is recorded,
  so the second request gets 409. The lock is in-process; replicas can still
  race within the trigger call.
- With several runnable pipelines, the endpoint took the suite relationship
  order while the details page took the name-ordered list, so the button
  could read permission and run state from a different pipeline than the
  one a run used. Both now pick the runnable pipeline with the lowest id.

Co-Authored-By: Claude Opus 5 <[email protected]>
Copilot AI review requested due to automatic review settings September 17, 2026 12:24

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.

… case

Review feedback on #33499: the 409 guard and its striped lock were keyed on the
pipeline, but what two runs contend for is the test case, which sits in its
table suite and in bundle suites, each with its own scheduled pipeline. The
guard could not see those overlaps, /trigger never used it, and the lock only
held within one server replica, so it read like a safety property it was not.

- IngestionPipelineRepository: remove runIngestionPipelineUnlessInProgress, the
  in-progress check, the running timeout and the per-pipeline lock; runTestCase
  goes through runIngestionPipeline like /trigger. The run id plumbing and the
  DAG failure callback stay: they make a run's statuses land on its own row.
- The lowest-id pipeline choice moves into runnablePipelineAmong, unit tested,
  since the IT that proved it relied on the 409 message.
- UI: a run in progress no longer disables Run now. The button keeps the
  Queued/Running label and the polling, and its tooltip says a click starts
  another run (message.test-case-run-already-in-progress, all locales). Only a
  missing or undeployed pipeline disables it. isLoading covers just the request,
  as the core Button ignores presses while loading.

Tests: the lock and in-progress unit tests and the 409 ITs go; an IT asserts a
run is accepted while the suite pipeline runs; Jest and Playwright assert the
button stays enabled with the advisory tooltip while a run is in progress.

Co-Authored-By: Claude Opus 5 <[email protected]>

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.

# Conflicts:
#	.github/playwright/impact-map.generated.json
#	openmetadata-service/src/main/java/org/openmetadata/service/clients/pipeline/airflow/AirflowRESTClient.java

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.

… entity

Review feedback on #33499: running one test case was a one-off endpoint, and
"profile this table now", "re-ingest this table" or "auto-classify this table"
would each have needed their own. This replaces it with one mechanism.

POST /v1/services/ingestionPipelines/run {entityLink, pipelineType}
(RunIngestionPipelineForEntity schema) runs the lowest-id enabled, deployed
pipeline of the type that owns the linked entity. EntityPipelineRunner holds the
steps every run shares - resolve the pipeline, authorise Trigger and enforce the
limits as /trigger does, check the scope is safe, resolve secrets, run - and two
registries hold what varies:

- RunnablePipelineResolver by entity type: a test case to its table suite's
  test suite pipeline (names are unique there, which a name-scoped run relies
  on); a table to its database service's profiler, metadata or auto
  classification pipeline. Usage and lineage are not served: a table filter
  does not bound their query logs.
- SourceConfigScoper by pipeline type: a test suite run to the test case; a
  profiler or auto classification run to exact, regex-escaped FQN filters on the
  table; a metadata run to the same filters with markDeleted* switched off, or a
  run that sees one table would soft-delete the rest, stored procedures left out,
  and rejected on incremental pipelines, whose next run would start from it.

The scope travels as RunOptions.sourceConfigOverride, a partial source config
whose top-level keys replace the deployed ones for the run: Airflow receives it
in the trigger conf and one step in CustomPythonOperator lays it over the
deployed config for every DAG type, replacing the test suite only testCases
param; K8s, Argo and Hybrid get a copy with it applied. The old
POST /dataQuality/testCases/{id}/run is removed and Run now calls the new one.

Tests: SourceConfigScopersTest reads every scope back through the generated
config classes, so a misspelt key fails; RunIngestionPipelineForEntityIT covers
test case and table runs, 400s for unsupported pairings and incremental
pipelines, 403 and 404s; Python tests cover the override for test suite and
metadata DAGs; Jest and Playwright follow the new endpoint.

Co-Authored-By: Claude Opus 5 <[email protected]>

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.

ShaileshParmar11 and others added 2 commits September 19, 2026 19:27
…union

A sparse deployed config can fit several source config variants: an auto
classification config with no database fields parses as the messaging one,
and re-validating the override with that class rejected the table filters a
scoped auto classification run adds. Validate the merged config through the
source config union instead, and leave empty deployed fields out so one
variant's empty fields cannot rule out another.

Co-Authored-By: Claude Opus 5 <[email protected]>
Airflow keys a DAG run by (dag_id, logical_date) and trigger_dag truncates
the date to the second by default, so a second trigger of the same pipeline
within one second failed with a unique violation. Now that a test case can be
run again while a run is in progress, a quick second Run now hit it.

Co-Authored-By: Claude Opus 5 <[email protected]>

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.

delete_dag_id removed the dag row and its runs, but never the task
instances, and a task instance pins the dag version it ran with a
RESTRICT foreign key. Deleting a dag that had executed anything was
therefore refused by the database. Airflow's own delete_dag walks every
table keyed by the dag in an order its foreign keys accept, so use it.

The integration test only passed before because trigger_dag truncated
logical_date to the second, which put the run before the test dag's
start date and so created no task instances at all.

Co-Authored-By: Claude Opus 5 <[email protected]>

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.

Triggering a pipeline for an entity aims it at that entity, so the Trigger
check on the pipeline is not the whole question: a caller who may not see a
test case or a table should not be able to aim a pipeline at it. Authorize
ViewBasic on the resolved entity before choosing a pipeline for it.

Co-Authored-By: Claude Opus 5 <[email protected]>

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.

@sonarqubecloud

Copy link
Copy Markdown

@ShaileshParmar11

Copy link
Copy Markdown
Contributor Author

Thanks Teddy, all three are in. Summary below; the inline threads point at the specific changes.

1. RunOptions (d1265ce). The scope is now an explicit argument: runPipelineWithOptions(pipeline, service, RunOptions) on PipelineServiceClientInterface. Three differences from your sketch:

  • The scope is a partial source config (sourceConfigOverride, whose top-level keys replace the deployed ones) rather than testCases. That way one field also carries point 3's table filters, and the client passes it on without knowing the pipeline type.
  • runId stays out of it. The client creates it per trigger and returns it on the response, so it isn't a caller input.
  • It's a new method name rather than a runPipeline overload. Existing runPipeline(p, s, null) calls (K8s here, ArgoServiceClient in Collate) would otherwise be ambiguous between the Map and RunOptions versions.

RunOptions is now the only channel. The interface default applies it onto a copy of the source config (RunOptions.applyTo) and runs that copy; K8s, Argo and hybrid all go through this path. Only Airflow overrides it, sending the options in the trigger conf instead. The copy never leaves that default method, so the "don't persist this" convention is gone. On the Airflow side, CustomPythonOperator now applies sourceConfigOverride for every DAG type, not only test suites.

2. Guard removed (f9081f7). Everything on your list is gone: the lock, the in-progress check, its settings and both tests. The run-id plumbing and the DAG failure callback stay. The IT now asserts a run is accepted while another is running. The Run now button stays enabled, with a tooltip saying a second run will start another. I agree addTestCaseResult is the right place if duplicate writes ever matter, and I've left it out of this PR.

Taking the guard out exposed a bug that is also on main. Airflow's trigger_dag zeroes the microseconds of logical_date by default, and a DAG run is unique per (dag_id, logical_date). So a second trigger of the same pipeline within one second failed, and /trigger hit this too. Fixed in 8c01ff6 (replace_microseconds=False), which then exposed an older one: delete_dag_id never deleted task instances, and a task instance pins its dag version with a RESTRICT foreign key, so on Airflow 3 deleting a DAG that had ever executed was refused by the database. It now uses Airflow's own delete_dag (08aae1d).

3. Generic endpoint (6aca653). POST /v1/services/ingestionPipelines/run {entityLink, pipelineType}, schema runIngestionPipelineForEntity.json. EntityPipelineRunner is the single path for every pipeline type:

  1. Parse the link and pick the resolver.
  2. Choose the pipeline: the lowest-id pipeline that is enabled and deployed, or 404 if there is none.
  3. Authorize the caller on the target entity and TRIGGER on the pipeline, and enforce limits.
  4. Build the scope, resolve secrets, and run.

What is registered:

  • Resolvers: testCase → its suite; table → its database service.
  • Scopers:
    • TestSuite → testCases: [name].
    • Profiler and autoClassification share one TableFilterScoper: exact, regex-escaped database/schema/table FQN patterns with useFqnForFiltering.
    • Metadata → the same filters, plus markDeleted{Tables,Schemas,Databases,StoredProcedures} set to false.
  • Everything else returns 400: usage, lineage, a link to a field, or a profiler run on a test case.

One more trap beyond mark-deleted: an incremental metadata pipeline starts each run from its last successful one. A scoped run that succeeds would therefore make the next scheduled run skip changes to every other table. The metadata scoper rejects scoped runs on incremental pipelines with a 400 rather than guess.

The UI stays on the test case page and now calls this endpoint. /dataQuality/testCases/{id}/run is gone and TestCaseResource is back to main.

Also since your review: greptile flagged that the endpoint authorized Trigger on the pipeline but never checked the caller against the entity the run is aimed at. That was right, and 7820379 adds a ViewBasic check on the resolved entity, covered by an IT that fails without it. I pushed back on the rest of that finding in its own thread.

Validation.

  • ITs: RunIngestionPipelineForEntityIT (15) and IngestionPipelineResourceIT (74), with the K8s client running against K3s.
  • End to end against a local Airflow:
    • Metadata: a scoped run re-ingests only the target table and leaves the other one alone. A control run with the same filters but mark-deleted left on does soft-delete it.
    • Profiler and auto-classification write results for the target table only.
    • A caller with Trigger but without ViewAll still gets a scoped run.
  • The auto-classification run found a plugin bug, fixed in e06ec45. A deployed config with few fields set parsed as the messaging variant, so the table filters were rejected.

The PR description has been rewritten to describe what actually shipped.

IngestionPipeline pipeline =
runnablePipelineAmong(resolver.pipelinesOwning(target, pipelineType))
.orElseThrow(() -> noRunnablePipeline(target, pipelineType));
authorizeTrigger(securityContext, pipeline);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

authorizeTrigger isn't calling a shared helper — it's a second hand-written copy of the pair that triggerPipelineInternal inlines (IngestionPipelineResource.java:1566-1577). The contexts are byte-identical (getResourceContextById(id) is just new ResourceContext<>(entityType, id, null)), so it's a duplicate rather than a divergence today, but it's one more place to remember when the trigger rule changes. Counting AppResource.triggerApplicationRun — which authorizes TRIGGER on the App and calls enforceLimits not at all — that's 3 independent implementations.

One real behavioural difference: /trigger returns 200 "Pipeline Client Disabled" before enforceLimits, whereas here the null-client check now lives inside repository.runIngestionPipeline, so limits are enforced first. With the pipeline client disabled and a limit exhausted, /trigger returns 200 and /run fails.

Aligned only by coincidence, too: CreateResourceContext reads owners off the in-memory entity, so owner-conditioned policies and limits evaluate the same on both paths only because RunnablePipelineResolver.pipelinesOfType happens to fetch with Entity.FIELD_OWNERS, matching getFields(FIELD_OWNERS) on the trigger path. Nothing enforces that — drop it and /run silently evaluates them against null owners.

This PR already made the equivalent move for the other duplicated concern: IngestionPipelineSecrets, whose javadoc says "a second implementation would be free to drift from this one on the details that matter for security." The same argument applies verbatim to the authorize + limits pair — a sibling helper that both triggerPipelineInternal and this call would make it zero new surfaces instead of one, and it's a smaller change than the secrets extraction already in the diff.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both moved into IngestionPipelineTriggers.authorizeTrigger(authorizer, limits, securityContext, pipeline), a sibling of IngestionPipelineSecrets in the same package, and triggerPipelineInternal and EntityPipelineRunner now both call it — one surface, not two.

The ordering difference you found is settled rather than papered over. /trigger's early 200 "Pipeline Client Disabled" was redundant with the one inside runIngestionPipeline, so I deleted the early return. Both paths now authorize, enforce limits, and then report a disabled client, so client-disabled + limit-exhausted behaves the same either way.

The owners coupling is now written down rather than coincidental: the helper's javadoc states the pipeline must be read with FIELD_OWNERS, because both the Trigger policy and the limits can be conditioned on owners and would otherwise evaluate against null. triggerPipelineInternal reads getFields(FIELD_OWNERS) and RunnablePipelineResolver.pipelinesOfType fetches Entity.FIELD_OWNERS, so both satisfy it.

I left AppResource.triggerApplicationRun alone — it authorizes TRIGGER on the App, not on the pipeline, so it is a different check rather than a third copy of this one. Happy to fold it in if you disagree.

Comment on lines +164 to +173
private PipelineServiceClientResponse runWithSecretsResolved(
UriInfo uriInfo,
SecurityContext securityContext,
IngestionPipeline pipeline,
RunOptions options) {
IngestionPipelineSecrets.decryptOrNullify(
authorizer, securityContext, repository.getOpenMetadataApplicationConfig(), pipeline, true);
ServiceEntityInterface service =
Entity.getEntity(pipeline.getService(), "ingestionRunner", Include.NON_DELETED);
return repository.runIngestionPipeline(uriInfo, pipeline, service, options);

@TeddyCr TeddyCr Sep 21, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Entity.getEntity(pipeline.getService(), "ingestionRunner", NON_DELETED) is still duplicated and is purely a precondition of runIngestionPipeline — byte-identical in both callers. A runIngestionPipeline(uriInfo, pipeline, options) overload that resolves the service itself would collapse this whole tail to one call. Keep the explicit-service overload for the callers with real variance (DataContractRepository passes a test suite; AppResource mutates ingestionRunner from the app first).

The one actual divergence: triggerPipelineInternal pre-sets the server connection with OpenMetadataConnectionBuilder(config) / (config, botName) before decrypting (IngestionPipelineResource.java:1578-1585); this doesn't. Same outcome today only because decryptOrNullify(forceNotMask=true) immediately overwrites it with OpenMetadataConnectionBuilder(config, pipeline), which derives the bot from the pipeline type. So the resource's pre-set — and with it the entire botName parameter of triggerPipelineInternal, which is only ever passed null — is dead. Worth deleting here rather than leaving one path holding a line the other doesn't: while it's there this method reads like it's missing a step, and if anyone ever makes that pre-set meaningful again, /run silently won't honour it.

(repository.getOpenMetadataApplicationConfig() vs the resource's own field is the same instance in the server, so no drift there.)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added runIngestionPipeline(uriInfo, pipeline, options) to IngestionPipelineRepository, which resolves Entity.getEntity(pipeline.getService(), "ingestionRunner", NON_DELETED) itself; both callers use it now. The explicit-service overload stays for the callers with real variance, exactly as you described — DataContractRepository passes a test suite and AppResource mutates ingestionRunner first.

botName and the OpenMetadataConnectionBuilder pre-set are deleted. You are right that decryptOrNullify(forceNotMask=true) overwrites it immediately, and the only two callers pass null.

One cross-repo consequence: Collate's AIAutomationResource calls the four-argument form with null, so it needs , null dropped when the submodule bumps. I will open that PR alongside this one.

Verified: RunIngestionPipelineForEntityIT 15/15, IngestionPipelineResourceIT + IngestionPipelineOwnerInheritanceIT 247 run / 0 failures, RunnablePipelineSelectionTest + RunIngestionPipelineImplTest 10/10. Pushed as dea17ae933.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correction on the botName deletion: I had to put a deprecated four-argument overload back, forwarding to the three-argument method.

Deleting it outright cannot merge in either order. Collate builds against OpenMetadata main (its .gitmodules pins branch = main, and collate-submodules resolves that branch rather than the gitlink), so maven-collate-ci on this PR compiles Collate main's four-argument call against this change and fails. Collate cannot go first either — the moment its call drops the argument, it stops compiling against today's main. Neither repo can be red, so the removal has to be two steps.

The overload carries no behaviour — it forwards, and the argument was always null. open-metadata/openmetadata-collate#6769 drops the Collate call site; once it merges I will send the three-line PR deleting the overload. Marked @Deprecated(forRemoval = true) with that issue named in the javadoc so it does not quietly become permanent.

…nd a scoped run

Running a pipeline and running it scoped to one entity each carried their
own copy of the Trigger authorization and the limits check, and
AppResource carries a third. Two copies of a security check are free to
drift on exactly the details that decide whether a run is allowed.

Move the pair into IngestionPipelineTriggers, alongside the secrets
helper that this endpoint already shares for the same reason. Its
javadoc records the precondition nothing enforced before: the pipeline
must be read with its owners, or an owner-conditioned Trigger policy and
the limits both evaluate against null owners.

This settles one behavioural difference. /trigger returned
200 "Pipeline Client Disabled" before enforcing limits while the scoped
run enforced limits first, so with the client disabled and a limit
exhausted one path succeeded and the other failed. The resource's early
return is redundant with the one in runIngestionPipeline, so drop it and
let both paths enforce limits, then report the disabled client.

Resolving the pipeline's own service was likewise duplicated and is a
precondition of the run rather than a choice, so add an overload that
resolves it. The explicit-service overload stays for the callers with
real variance - a data contract passes a test suite, an app sets the
ingestion runner first.

The botName parameter of triggerPipelineInternal is always null, and the
server connection it pre-set is immediately overwritten by
decryptOrNullify, which derives the bot from the pipeline. Delete both:
while the pre-set is there the scoped run reads as if it skips a step,
and a future change that made the pre-set meaningful would silently not
apply to the scoped run.

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.

…ps it

Deleting botName in one step cannot merge: Collate builds against
OpenMetadata main, so the four-argument call in its AIAutomationResource
breaks the moment this lands, and maven-collate-ci is red until Collate
updates - which it cannot do first, for the mirror-image reason.

Keep a deprecated overload that forwards to the three-argument method so
both repositories compile in either order. It carries no behaviour: the
argument was always null. Delete it once Collate has dropped the
argument (open-metadata/openmetadata-collate#6769).

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.

@gitar-bot

gitar-bot Bot commented Sep 22, 2026

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

🔴 High risk · New entity-scoped ingestion triggers alter authorization and stored-data processing behavior.

Adds entity-scoped ingestion pipeline runs with a generic POST /v1/services/ingestionPipelines/run endpoint, exposing "Run now" on the test case details page. Includes resolver and scoper implementations for test cases and tables, authorization checks, per-run source config overrides for Airflow and K8s, and comprehensive Java, Python, Jest, integration, and Playwright test coverage. No issues found.

✅ 1 closed
Closed: Bug: UI never ages out stale QUEUED runs, button stuck disabled

📄 openmetadata-ui/src/main/resources/ui/src/components/observability/TestCaseDetail/RunTestCaseButton/RunTestCaseButton.utils.ts:52-66
getActiveRunState() applies a timeout only to RUNNING statuses; the QUEUED branch returns Queued for any queued status regardless of timestamp (RunTestCaseButton.utils.ts:78-83). Its comment claims "The server already drops queued runs that never started", but the pipelineStatuses field the button fetches via getIngestionPipelines (list endpoint, fields=pipelineStatuses) is populated by getRecentPipelineStatuses, which does NOT drop stale queued statuses — only listPipelineStatus applies dropStaleQueuedStatuses. So when a queued run never starts (e.g. a worker that dies before adopting the run, or a K8s/Argo runner where the DAG-level failure callback never fires), the server's hasRunInProgress correctly ages the queued run out after queuedStatusTimeoutSeconds and returns 200 for a new run, but the UI keeps runInProgress true forever: the button stays disabled showing "Queued", polls every 5s indefinitely, and the user has no recourse. This defeats the queued-timeout backstop the PR deliberately designed on the server side.

Review coverage

📋 Rules No rules evaluated

🧪 Functional validation Not enabled · Set up

🤖 Auto-approval Not enabled · Set up

Options

Display: compact → Counting what did not apply, without listing it.

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

@sonarqubecloud

Copy link
Copy Markdown

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

safe to test Add this label to run secure Github workflows on PRs UI UI specific issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants