Skip to content

fix(workflows): Git sink batch recovery and per-entity batch nodes - #34373

Merged
yan-3005 merged 23 commits into
mainfrom
fix/git-sink-hardening
Oct 12, 2026
Merged

yan-3005 merged 23 commits into
mainfrom
fix/git-sink-hardening

Conversation

@yan-3005

@yan-3005 yan-3005 commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Describe your changes:

Fixes problems in periodic batch workflows with a sink node: failures were reported as success, a server crash mid-batch left instances RUNNING with no way to clear them, and a large batch held one async job for a long time.

  • Failure status. A sink failure that no failure branch handles is now recorded on the trigger process, so the instance ends FAILURE instead of FINISHED. WorkflowInstanceRepository now also honours the process-level failure flag.

  • Terminate endpoint. POST /v1/governance/workflowInstances/{id}/terminate?reason= (admin only).

    • Clears an instance and its Flowable rows, including instances whose job locks are still held by a server that crashed.
    • If a job is executing, the endpoint records a stop request and returns 202. The sink stops after its current sub-batch, the trigger stops fetching, and the instance ends FAILURE ("Terminated by admin: ").
    • Open workflow-managed tasks of the instance are closed once the process delete succeeds.
    • The stop request and the end-of-run status are written as partial JSON updates (JSON_SET / jsonb_set), so neither write overwrites the other, and a stop request is recorded only while the instance is RUNNING. The end-of-run write re-reads the row afterwards, so a stop accepted between its read and write still ends the instance FAILURE. Once the trigger's process has ended it is marked so (variables.processEnded) and no stop request is accepted, an EXCEPTION end included; an EXCEPTION from a failed job attempt that Flowable retries still accepts one.
  • Batch sizing.

    • One batch-sink execution handles at most 5000 entities, so a crash or stop costs at most one chunk.
    • Sub-batches are prefetched while the provider writes.
    • SinkProvider gains nextBatchSize() and finishBatch() (both with defaults) so providers can size sub-batches and flush at the end of a batch.
    • A sub-batch counts toward the consecutive-failure limit only when it made no progress, so providers that stage files for finishBatch are not cut off by a single bad entity, and a sub-batch whose fetches all failed counts as failed.
  • Batch workflows evaluated per entity. When a periodic workflow has a batch sink, the main workflow runs once per batch. Condition nodes (check entity attributes, check change description) now evaluate every entity and pass only the matching ones on; action nodes (set attribute, certification, glossary term status, rollback) apply to every entity. A batch that an earlier node emptied stays empty: later nodes and the sink handle no entity instead of falling back to the batch's first entity. Batch-sink workflows with nodes that can't run per batch (approvals, tasks, run app, ingestion, data completeness) or with branches the batch list can't follow are rejected on save.

  • No queries in Git sinks. Saving a Git-sink workflow whose trigger lists query returns 400; Git-sink workflows are deployed without a query trigger; the workflow builder leaves query out of the entity types (including "All") when the workflow has a Git sink.

  • No migration here. The 2.1.0 sink workflow migration (encrypting stored sink secrets, redeploying batch-sink workflows, removing query from Git-sink triggers) runs from the Collate migrations in open-metadata/openmetadata-collate#7033, since the Git sink workflow ships with Collate.

  • Git sink config. gitSinkConfig.json gains two optional fields:

    • signingKey {privateKey, passphrase}, both format: password.
    • allowUnsignedFastPush (boolean, default false).

    Existing definitions are unaffected.

  • Sink task form.

    • Saving now merges the form values over the stored node config. Fields the form doesn't render are kept instead of being dropped: batchMode, syncMode, entityFilter, timeoutSeconds, outputFormat, and in sinkConfig retryConfig, timeout, signingKey, ….
    • New fields for the signing key (multi-line) and passphrase, plus the unsigned-fast-push checkbox. Labels are translated in every locale.
    • Focusing a stored secret clears its visual mask; leaving it untouched preserves the stored value, and Backspace or Delete in the cleared field removes the stored secret. Replacement text, including leading/trailing *, is saved verbatim. Git-sink saves remove query from an existing trigger selection.
  • Sink secrets. Stored sink password fields are encrypted when a Fernet key is configured. Sending the same plaintext secret again preserves its ciphertext when the primary Fernet key decrypts it, so it does not create a version or redeploy; ciphertext of an older rotation key is encrypted again with the primary key. REST workflow responses and MCP workflow reads/write responses mask sink credentials; MCP change-event creation masks them too. Other MCP entity types are outside this change.

  • Compatible edits. Batch/sink rules run on create and when the graph or trigger changes (compared with secrets masked), allowing unrelated edits to older definitions. The copied-secret guard runs for copy/move PATCH operations.

  • Review hardening. Updates (PUT and PATCH) and redeploys keep a suspended workflow suspended; sink exclusions are declared by provider registration metadata; non-batch providers process each entity, and a write that throws fails only that entity; skipped counts reach node outputs and summaries; batch action errors retain their original cause.

Type of change:

  • Bug fix
  • Improvement

High-level design:

  • SinkTaskDelegate keeps a persisted failure variable. SubWorkflowFailureListener propagates it from the main workflow to the trigger process when the failure is not routed to a branch.
  • WorkflowInstanceTerminator deletes the root process (it cascades to call-activity children) and marks the OM instance FAILURE.
    • Lock conflicts, deadlocks and optimistic-lock failures during the delete map to a conflict, so callers get a stop request instead of a 500.
    • WorkflowStopRequests stores the stop marker on the OM instance record. The marker lives in the OM DB, so it works across servers.
  • PeriodicBatchEntityTrigger caps a single execution at MAX_SINGLE_EXECUTION_BATCH_SIZE = 5000. SubBatchPrefetcher overlaps fetching with writing.

Testing / benchmarks before the review follow-up

Measured locally against a real GitHub repository, using the Collate Git sink as the provider:

  • Crash test: a server was killed with kill -9 mid-batch. The instance stayed RUNNING, with job and execution locks held by the dead server for the full 15-day lock time. terminate cleared it: 0 Flowable rows left, instance FAILURE.

  • Failure status: a failing sink, with an invalid token or forced failures, now ends the instance FAILURE. Before, it ended FINISHED.

  • Unit tests: openmetadata-service governance, workflow, secrets, migration and JSON-patch tests: Tests run: 1232, Failures: 0, Errors: 0, Skipped: 0. UI: SinkTaskForm, DataAssetFormSection and WorkflowConfigUtils tests, Tests: 63 passed.

  • Integration tests (CI on the previous head, all lanes green):

    Database parallel global-state rdf retry-queue multi-node
    MySQL + Elasticsearch 16,631 run, 0 failed 513, 0 218, 0 36, 0 23, 0
    PostgreSQL + OpenSearch 16,631, 0 513, 0 218, 0 36, 0 23, 0
    PostgreSQL + Elasticsearch + Redis 16,639, 0 513, 0 — 36, 0 23, 0

    The workflow ITs added here (WorkflowDefinitionResourceIT: terminate of a stale foreign lock 200 and of an executing sink job 202, batch condition filtering, unsupported batch shapes, Git-sink query rule, secret masking/encryption, a stop refused once the process ended) ran locally on MySQL + Elasticsearch and Postgres + OpenSearch before this review follow-up: Tests run: 9, Failures: 0, Errors: 0 on each.

  • Collate: open-metadata/openmetadata-collate#7033 built against this branch passes its integration suite (MySQL 502 run, Postgres 505 run, 0 failures).

Known limits

  • Only batch sinks and the periodic fetch loop check the stop request. Other long-running jobs get 202 and finish their current job before the instance turns FAILURE.
  • After a stop the sink reports failure, because a new result value would have no matching edge and Flowable would retry the job. So a workflow that routes failure to further nodes runs them after a stop.
  • Terminate bounds its database lock wait. A foreign lock can belong to a live executor: removing its process cannot interrupt external work already running there, particularly non-periodic jobs. Side effects can continue after a 200 response.
  • force is no longer needed; ?force=true is accepted and ignored.
  • Flowable keeps earlier deployments of a workflow, and those still hold the plaintext BPMN until they are removed. Deployments with running instances can't be removed.
  • change_event rows written before the Collate 2.1.0 migration still hold the plaintext entity JSON.
  • Rolling back to a build without this change after secrets are encrypted hands ciphertext to the sink provider.
  • New deployments inject failureHandledByBranchExpr, batchExecutionExpr and batchContinuingOutcomeExpr. Older executors reject fields they do not declare. Drain jobs and stop older executors before deploying upgraded definitions; mixed-version rolling execution and rollback require compatible deployment/database state.
  • Rotate credentials stored before the upgrade: migration does not rewrite old change events, audit logs or backups, and deployments with running instances may retain plaintext.
  • Fast push stages up to 5,000 entities until the final flush. A crash before that push lands loses that batch's local staging. A job retry can repeat preceding node actions; use idempotent actions.

Checklist:

  • I have read the CONTRIBUTING document.
  • I have commented on my code, particularly in hard-to-understand areas.
  • I have added tests around the new logic.

Live end-to-end and scale results

Run on a Collate server built from this branch + open-metadata/openmetadata-collate#7033, MySQL, Elasticsearch, a real GitHub repository, -Xmx2g.

Functional (prior live runs): trigger filters (only the filtered schema synced), fetch iteration (3 loops, all entities synced, 5000 cap), check node in batch mode (only matching entities synced), action nodes in batch mode (every entity updated), unsupported batch shapes rejected, query rejected for Git sinks and dropped on redeploy, FAILURE on bad token / repo / URL, terminate of a running batch (202) and of a crashed instance after kill -9 (200, no Flowable rows left), masking on tested REST workflow routes and encryption of tested definitions/version rows/current deployments, event-based single-entity sync, JGit fast push over HTTPS (unsigned and signed).

Run Entities Time Notes
API mode 20,000 tables 4.3 min flat 77–86 entities/s per batch, all commits Verified
Fast mode (unsigned) 20,000 1.3 min 249 entities/s
Fast mode (unsigned) 100,000 6.8 min flat 210–333 entities/s across 20 batches
API mode, one folder growing to 20k files 20,000 5.4 min 110 → 52 entities/s (GitHub commit cost grows with folder size)
Check node → sink 20,000 (10,000 match) 2.3 min condition phase ~9.5 s per 5,000 (parallel)
Set-attribute node → sink 4,800 ~2.4 min every table updated, 0 lock errors

No full GC in any run; heap after GC stayed at 340–475 MB; GitHub returned no 499/502/504.

Review follow-up verification (2026-10-08, head 592b9e5)

  • openmetadata-service governance, secrets and workflow repository unit tests: Tests run: 767, Failures: 0, Errors: 0, Skipped: 0.
  • MCP workflow read/write/change-event masking: Tests run: 46, Failures: 0.
  • WorkflowDefinitionResourceIT (sink, batch, terminate, Git-sink and suspension cases): Tests run: 18, Failures: 0, Errors: 0 on MySQL + Elasticsearch and on PostgreSQL + OpenSearch. Covers both trigger failure statuses, batch action nodes, suspension across PATCH and PUT, the secret no-op and copy guard, and bounded waits on held rows during terminate.
  • Workflow builder Jest: SinkTaskForm 54 passed; the other changed suites (78 tests across 5 suites) passed earlier in the follow-up. Changed UI files lint with no errors and pass Prettier.
  • Chromium GitSinkTokenMask spec: 2 passed locally before the Backspace/Delete removal change; CI runs it on this head.
  • Each behaviour fix has a unit or integration test that fails without it.

🤖 Generated with Claude Code

- Persist sink failures on the trigger process so periodic batch
  instances end FAILURE instead of FINISHED when a sink node fails
  without a failure branch.
- Add POST /v1/governance/workflowInstances/{id}/terminate (admin) to
  clear instances left RUNNING, including ones whose job locks are held
  by a server that no longer exists; a running sink stops after its
  current commit.
- Cap a single batch-sink execution at 5000 entities, prefetch
  sub-batches, and let providers size sub-batches and finish a batch.
- Close open workflow-managed tasks when an instance is terminated.
Copilot AI balanced review requested due to automatic review settings October 1, 2026 12:03
@yan-3005
yan-3005 requested a review from a team as a code owner October 1, 2026 12:03
@github-actions

github-actions Bot commented Oct 1, 2026

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 github-actions Bot added backend safe to test Add this label to run secure Github workflows on PRs labels Oct 1, 2026

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 review overview

🟡 Changes recommended

Stop-request persistence is race-prone, task closure can corrupt the 202 fallback path, and the active-job flow lacks integration coverage.

Review effort: Balanced
Findings: 1 High severity · 1 Medium severity

Open (2)
What changed in this PR

Adds recoverable batch-sink execution, administrative workflow termination, correct failure propagation, bounded batching, and sink-secret masking.

Changes:

  • Adds cooperative and forced workflow termination.
  • Propagates sink failures and bounds/prefetches batches.
  • Masks sink credentials and expands regression coverage.
File Description
WorkflowDefinitionMaskerTest.java Tests sink-secret masking.
WorkflowInstanceRepositoryTest.java Tests stop-state persistence.
WorkflowTaskCloserTest.java Tests task cleanup.
WorkflowInstanceTerminatorTest.java Tests termination outcomes.
WorkflowFailureListenerTest.java Tests intentional cancellation handling.
SubWorkflowFailureListenerTest.java Tests child failure propagation.
PeriodicBatchEntityTriggerTest.java Tests failure mapping and batch caps.
NoOpTriggerTest.java Tests failure propagation.
FetchEntitiesImplTest.java Tests pagination and stopping.
SinkTaskTest.java Tests failure-branch detection.
SinkTaskDelegateTest.java Tests batching, prefetching, and stopping.
SinkResultTest.java Tests bounded serialization.
WorkflowDefinitionMasker.java Masks and restores sink credentials.
WorkflowInstanceResource.java Adds the terminate endpoint.
WorkflowDefinitionResource.java Masks workflow API responses.
WorkflowInstanceStateRepository.java Fails running stages.
WorkflowInstanceRepository.java Persists stop requests and final status.
WorkflowDefinitionRepository.java Restores and validates secrets.
WorkflowTaskCloser.java Closes workflow-managed tasks.
WorkflowStopRequests.java Reads persisted stop markers.
WorkflowInstanceTerminator.java Orchestrates termination.
WorkflowInstanceListener.java Exposes UUID validation.
WorkflowFailureListener.java Whitelists admin termination.
Workflow.java Defines termination cause.
SubWorkflowFailureListener.java Propagates child failures.
MainWorkflow.java Supplies edges to nodes.
PeriodicBatchEntityTrigger.java Caps batches and maps failures.
NoOpTrigger.java Maps child failures.
FetchEntitiesImpl.java Stops fetching on request.
EventBasedEntityTrigger.java Maps child failures.
SinkTask.java Detects handled failure branches.
SubBatchPrefetcher.java Prefetches entities concurrently.
SinkTaskDelegate.java Implements bounded batch execution.
SinkResultSummary.java Creates bounded persisted results.
SinkResult.java Excludes causes from JSON.
SinkProvider.java Adds batch sizing and finalization hooks.
NodeFactory.java Passes workflow edges to sinks.
WorkflowInstanceConflictException.java Adds HTTP 409 mapping.
WorkflowDefinitionResourceIT.java Covers masking and stale-lock termination.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

… ended

The trigger's process-end listener now marks the instance's process ended
(variables.processEnded) before reading the row back, and requestStop
refuses a marked instance. An EXCEPTION recorded for a failed job attempt
that Flowable retries carries no mark, so a stop still lands while the
process runs on, but an EXCEPTION the process ended with no longer accepts
a stop that nothing would apply.

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.

@yan-3005

yan-3005 commented Oct 6, 2026

Copy link
Copy Markdown
Contributor Author

Update on Stop request on an instance that ended EXCEPTION: fixed in 23b3a33, which replaces my earlier "not changing this".

The endedAt IS NULL guard couldn't separate the two cases, because a failed job attempt records EXCEPTION with endedAt set. So the end of the trigger's process now leaves its own mark:

  • WorkflowInstanceListener's process-end path calls the new WorkflowInstanceRepository.recordProcessEnd. It records the end as before, sets variables.processEnded, and only then reads the row back for a missed stop request.
  • requestStop refuses a row carrying processEnded (MySQL JSON_EXTRACT(json, '$.variables.processEnded') IS NULL, Postgres json #> '{variables,processEnded}' IS NULL), so terminate answers 409 instead of a 202 nothing would apply.
  • WorkflowFailureListener (failed attempt, retried) and MainWorkflowTerminationListener still go through updateWorkflowInstance without the mark, so a stop still lands on an EXCEPTION whose process runs on.
  • A stop accepted between the end write and the mark is read back after the mark and ends the instance as FAILURE.

Tests:

  • WorkflowInstanceRepositoryTest: three new cases (EXCEPTION end refuses, failed attempt accepts, stop between end write and mark is applied).
  • WorkflowDefinitionResourceIT#test_terminateStopRequestIsRefusedOnceTheProcessEnded runs the real SQL: Tests run: 9, Failures: 0 on MySQL + Elasticsearch and on Postgres + OpenSearch.

@harshach harshach left a comment •

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.

Reviewed at 23b3a33a950.

The core holds up well. I traced the stop and terminate paths end to end:

  • The stop request and the end-of-run status are written with JSON_SET / jsonb_set, and status is a generated column on both MySQL and Postgres, so WHERE status IN (…) sees the live value. The read-back after the end write catches a stop that lands in between, and the processEnded mark closes the stop-after-EXCEPTION window.
  • Deleting a process runs no execution listeners in Flowable, so markTerminated reading and then writing the status can't be overwritten, and a RUNNING record left with no process is repaired by terminating again.
  • Only the sink and BatchEntities write global_failure, so the new output mapping on every trigger type leaves approval and task workflows unchanged.

Before merge

  1. Link an issue. Validate PR Metadata is the only red check.
  2. Add an IT for the headline fix: a sink that fails, with no failure branch, ends the instance FAILURE (it used to end FINISHED). No IT asserts this today; the FAILURE assertions in WorkflowDefinitionResourceIT all come from terminate. The output mapping through the multi-instance call activity is the part unit tests can't prove, and the CapturingSink registry swap already in the IT makes this a short test.
  3. Sending the same plaintext secret again is never a no-op. getUpdater restores masked values only (WorkflowDefinitionRepository.java#L103-L111), and encryptSecret encrypts any plaintext again (WorkflowSinkSecrets.java#L62-L66). Fernet output is random, so every PUT from an SDK or IaC client that carries the real token bumps the version, emits a change event and redeploys the workflow, which recreates the periodic timer jobs. Keep the stored ciphertext when it decrypts to the incoming value.
  4. Merge together with open-metadata/openmetadata-collate#7033. That PR currently conflicts, and its .gitmodules pins branch = fix/git-sink-hardening, which needs to go back to main once this lands.

Functionality (minor)

  1. The copied-secret guard can reject unrelated edits. requireSecretsOnlyInSecretFields substring-matches stored secrets against every text field, updatedBy included (WorkflowDefinitionMasker.java#L245-L256, #L285-L302). With a short secret that is still plaintext (no Fernet key, or a row never saved again), for example password admin edited by the admin user, every PUT, PATCH and restore returns 400. Running the check only for copy/move patches (readsFromAnotherPath already detects them) would avoid it.
  2. MCP reads skip the masker. get_entity_details returns the stored entity as a map (GetEntityTool.java#L267-L268), so sinkConfig comes back as stored: ciphertext normally, plaintext for rows never saved again. The description says secrets are masked on every read path.
  3. Stored definitions that break the new rules can't be edited at all. validateBatchExecution and validateGitSinkEntityTypes run on every write (WorkflowDefinitionRepository.java#L232-L253), so even a description PATCH returns 400 until the graph is fixed. OSS has no migration for this; worth a release note.
  4. Rolling upgrade and downgrade. Every sink task now deploys with a failureHandledByBranchExpr field extension (SinkTask.java#L78-L84), and batch nodes with batchExecutionExpr and batchContinuingOutcomeExpr. Flowable rejects a field extension the delegate class doesn't declare (Field definition uses non-existing field), so an older server that picks up those jobs fails them. "Known limits" only covers the ciphertext rollback.
  5. Batch mode with a provider that lacks batch support falls back to global_relatedEntity (SinkTaskDelegate.java#L154-L165): the batch's first entity, even when a condition filtered it out, and the rest of the batch is never written. No provider does this today, but BatchExecutionPlan could reject the combination, or the sink could treat it as an empty batch.
  6. Terminate across nodes. A lock held by another live node is treated as a dead node's lock and the process is deleted (WorkflowInstanceTerminator.java#L54-L58). For a non-periodic workflow, that node's job keeps applying its side effects after the caller got a 200. That belongs in the endpoint description, not only the class Javadoc.
  7. UI: query stays in an earlier selection. getTriggerDataAssets filters the options only (NodeConfigSidebar.tsx#L189-L196). Picking "All" first and adding a Git sink afterwards, the usual order, keeps query selected, and the save returns 400.
  8. UI: replaceMask drops real * at the edges of a value pasted over the mask (SinkTaskForm.tsx#L162-L182). Pasting *hunter2* saves hunter2, in a password field where the user can't see it.
  9. Batch action nodes lose the root cause when every entity fails. ActionOutcome.record writes the summary and the first entity's stack trace, then throws a BpmnError (BatchEntities.java#L216-L221). The node's own catch (Exception) catches it and overwrites global_exception with the BpmnError's trace (SetEntityAttributeImpl.java#L49-L53; the certification and glossary-status nodes do the same).

Performance

Good: the sink prefetch keeps at most two sub-batches in memory, syncResult is bounded (20 errors, 100 commit ids, no stack traces), a job handles at most 5000 entities, the stop check is one read per sub-batch, and batch-node threads are capped against the DB pool. Worth knowing:

  • All nodes of a batch run in one Flowable transaction, so a late unhandled failure re-runs every node action on retry. Most of them are idempotent.
  • Terminate can hold the HTTP request for the DB lock-wait timeout (about 50 s on MySQL), which may exceed an ingress timeout.
  • Each batch-node execution creates its own 8-thread executor, and the inline path skips the shared permits (BatchParallelism.java#L76).

Tests

The ITs are strong and run against a real database: terminate of a stale foreign lock (403, then 200 with no runtime rows, then 409), terminate of an executing sink (202, then FAILURE after one sub-batch), the stop refused once the process ended, the batch condition filter (fails without per-entity evaluation), the Git-sink query rule, and masking plus ciphertext in the stored rows, the version rows and the deployed BPMN. The unit tests mostly use fakes that follow the real SQL semantics, real Fernet and real threads rather than mock wiring. Gaps besides #2:

  • Set attribute, certification, glossary status and rollback in batch mode are covered only by verify(patch) unit tests. Rollback is destructive and deserves an IT.
  • No test for the failure wiring on EventBasedEntityTrigger, for a PATCH of a stored definition that breaks the new rules, or for the MCP read path.
  • No Playwright test for the sink form's mask round trip.
  • BatchParallelismTest.java#L31 and #L112 sleep by waiting on a CountDownLatch nobody counts down.

Code quality

  • Scope. The title covers batch-sink recovery, but the PR also adds secrets at rest, masking, per-entity batch evaluation, the signing key and the UI form. The secrets and masking part would be easier to review and revert on its own; at least the title should say so.
  • WorkflowDefinitionMasker is 514 lines of statics doing masking, restore, three write guards, the encryption traversal and migration probes. The new file has a "Copyright 2021" header. hasSinkSecrets, hasPlaintextDeployedSecret and WorkflowSinkSecrets.encrypt(JsonNode) have no caller in OSS; the Collate migration is their only user, so they need a comment saying so.
  • GitSinkEntityTypeRule hard-codes a Collate provider's limit in OSS core by sink type (GitSinkEntityTypeRule.java#L47). A capability on SinkProvider, which this PR already extends, would fit better.
  • Nits: a new bare catch (Exception e) (WorkflowHandler.java#L1896); the read, branch and record block is repeated in six node implementations; "governance-bot" is back as a string literal in SetEntityAttributeImpl; endStateOf in WorkflowInstanceRepository writes stage rows from what reads as a pure function.

@harshach harshach left a comment

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.

Line-level notes for my review above; the numbers match its items. Items that aren't tied to a line (the linked issue, the merge order with Collate, performance, scope) stay there.

Secrets:
- A sink secret sent again in plaintext keeps its stored ciphertext when the
  primary Fernet key decrypts it to the same value, so the update is a no-op;
  ciphertext of an older rotation key is encrypted again with the primary key.
- The guard against copying a secret into another field runs only for JSON
  patches with copy or move operations, through a new EntityRepository
  validatePatch hook, so unrelated edits are no longer rejected.
- MCP entity reads, write responses and change events mask workflow sink
  secrets.
- The secret write guards move from WorkflowDefinitionMasker into
  WorkflowDefinitionSecretGuards.

Workflow definitions:
- The batch and sink rules run on create and on updates that change nodes,
  edges or trigger, compared with secrets masked, so a stored definition that
  breaks them can still be edited elsewhere.
- An update keeps the stored suspended flag, and a redeploy of a suspended
  workflow leaves its new trigger definitions suspended.
- The entity types a sink cannot sync come from its registered provider
  factory (SinkEntityTypeRule) instead of a Git-specific rule in core.
- Manual triggering fails when the stored definition cannot be read instead
  of starting an excluded trigger process.

Batch runs:
- A provider without batch support writes every entity of the batch one by
  one; a write that throws fails that entity only.
- Action nodes rethrow BpmnError unchanged, keeping the per-entity failure
  summary, and the six nodes share one read/branch/record path.
- Inline batch work takes a shared permit; skipped entities are counted in
  the sink result and node outputs.

Terminate:
- The delete waits a bounded time for row locks on MySQL and PostgreSQL, and
  the endpoint documents that a job running on another server keeps applying
  its effects.

UI:
- A Git-sink workflow never saves a trigger listing query.
- Masked secret fields clear on focus, restore the mask on blur without
  typing, keep typed values verbatim, and Backspace/Delete removes the stored
  secret.

Tests: integration tests for sink failure status (periodic and event-based),
batch action nodes, suspension across PATCH and PUT, bounded terminate waits,
secret no-op and copy guard; unit tests for each change; Playwright spec for
the token mask round trip.

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 Oct 8, 2026

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: 837 → 838
- 1 added, 0 removed, 13 changed spec-list

New source→spec entries:
  openmetadata-ui/src/main/resources/ui/src/components/WorkflowDefinitions/WorkflowBuilder/forms/SinkTaskForm.tsx

Entries whose spec list changed:
  openmetadata-ui/src/main/resources/ui/playwright/constant/config.ts
  openmetadata-ui/src/main/resources/ui/playwright/e2e/fixtures/pages.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/entity.ts
  openmetadata-ui/src/main/resources/ui/playwright/utils/waitHelpers.ts
  openmetadata-ui/src/main/resources/ui/src/components/WorkflowDefinitions/WorkflowBuilder/CustomControls.tsx
  openmetadata-ui/src/main/resources/ui/src/components/WorkflowDefinitions/WorkflowBuilder/NodeConfigSidebar.tsx
  openmetadata-ui/src/main/resources/ui/src/components/WorkflowDefinitions/WorkflowBuilder/NodeFormSidebar.tsx
  openmetadata-ui/src/main/resources/ui/src/components/WorkflowDefinitions/WorkflowBuilder/WorkflowControls.tsx
  … and 3 more

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

@yan-3005

yan-3005 commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

@harshach thanks for the review. Everything is addressed in 592b9e5; replies are on each inline comment. The rest:

  • Linked issue: added skip-pr-checks; there's no separate issue for this work.
  • Merge order: this goes first, then open-metadata/openmetadata-collate#7033 with its .gitmodules set back to main.
  • Scope: the title now names the secrets and masking part. It stays in this PR, and the masking goes to 2.0 as its own minimal backport.
  • Test gaps:
    • ITs added for set attribute + certification and for rollback + glossary status in batch mode, for event-based failure wiring, for a PATCH of a stored definition that breaks the rules, and for the MCP read path.
    • Playwright spec added for the mask round trip.
  • Performance notes:
    • The terminate lock wait is bounded now.
    • The inline batch path takes permits.
    • Retry re-running node actions in one transaction is in Known limits.
  • Verification: WorkflowDefinitionResourceIT workflow cases ran 18/0 on MySQL and on Postgres; the unit tests are in the description.

@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ UI Checkstyle passed — lint findings in changed files

🔍 ESLint findings in this PR's files — 0 error(s), 6 warning(s)

Errors block the build. Warnings do not yet — they are rules whose backlog is still
being worked down, listed so this PR does not add to it. See docs/ui-code-quality-gate.md.

0 error(s), 6 warning(s) across 3 changed file(s).

Count Rule
5 react-hooks/exhaustive-deps
1 openmetadata-imports/no-api-calls-in-iteration
All findings
Location Rule Message
🟡 src/components/WorkflowDefinitions/WorkflowBuilder/NodeConfigSidebar.tsx:170:39 openmetadata-imports/no-api-calls-in-iteration Avoid issuing one API request per item. Fetch at the data owner, use a bulk endpoint, or use useQueries with an intentional concurrency policy.
🟡 src/components/WorkflowDefinitions/WorkflowBuilder/NodeConfigSidebar.tsx:223:6 react-hooks/exhaustive-deps React Hook useEffect has a missing dependency: 'node'. Either include it or remove the dependency array.
🟡 src/components/WorkflowDefinitions/WorkflowBuilder/NodeConfigSidebar.tsx:367:6 react-hooks/exhaustive-deps React Hook useEffect has a missing dependency: 'node'. Either include it or remove the dependency array. If 'setBackendConfig' needs the current value of 'node'
🟡 src/components/WorkflowDefinitions/WorkflowBuilder/forms/SinkTaskForm.tsx:309:6 react-hooks/exhaustive-deps React Hook useEffect has a missing dependency: 't'. Either include it or remove the dependency array.
🟡 src/pages/WorkflowDefinitions/WorkflowBuilder/WorkflowBuilder.tsx:352:6 react-hooks/exhaustive-deps React Hook useEffect has missing dependencies: 'edges' and 'nodes'. Either include them or remove the dependency array.
🟡 src/pages/WorkflowDefinitions/WorkflowBuilder/WorkflowBuilder.tsx:416:5 react-hooks/exhaustive-deps React Hook useCallback has missing dependencies: 't' and 'workflowLogic'. Either include them or remove the dependency array.

Fix locally (fast - only checks files changed in this branch):

make ui-checkstyle-changed

Sink and batch node code moves to the generic EntityInterface<?> from main.

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.

Resolves the secret fields of a sink config through a lookup keyed by the
sink type value, the same key the sink provider registry uses. A sink type
without an entry masks every known secret field.

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.

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

🚦 Removed from the merge queue — failed_checks (2026-10-12T05:10:33Z)

Blocked the queue: playwright-summary

Failed Playwright tests:

  • Features/Workflows/GitSinkTokenMask.spec.ts › saving the sink without typing a token keeps the stored token

The node config sidebar keeps focus inside itself, so a blur to the page body
is turned back into focus on the token field. The test leaves the field for
the base path field instead, as a user does.

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.

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 Oct 12, 2026

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

🔴 High risk · Batch actions now apply across entities, so targeting errors could modify many catalog records; admin termination also deletes workflow process trees.

Fixes periodic batch workflows with sink nodes so failures end as FAILURE, adds an admin terminate endpoint for stuck instances, caps batch execution at 5000 entities, and evaluates batch workflows per entity. Resolved this session: the requestStop read-modify-write that could revert a just-finished instance, the workflow handler init failure that aborted the v2.1.0 data migration, an emptied batch falling back to the original batch's first entity, and stop requests landing on instances whose process already ended with EXCEPTION. No open issues found.

✅ 4 closed
✅ Edge Case: requestStop read-modify-write can revert a just-finished instance

📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/WorkflowInstanceRepository.java:121-134 📄 openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/WorkflowInstanceTerminator.java:132-143
requestStop reads the WorkflowInstance JSON, adds stopRequest, then writes the whole document back with no lock or version check. The trigger's end listener updates the same row in updateWorkflowInstance, so the two can interleave. Suppose requestStop reads the RUNNING record, the process then ends and writes FINISHED/FAILURE with endedAt, and requestStop writes last. That final write puts the row back to RUNNING with no endedAt. If the job lock is still visible during the end-of-job commit, terminate returns 202, and the instance stays RUNNING until an admin calls terminate again.

Fix: update only the variables.stopRequest field with a JSON-merge/partial update, or re-read the row inside the update and skip the write when the status is no longer RUNNING. A version-checked update would also work.

✅ Edge Case: Workflow handler init failure aborts the v2.1.0 data migration

📄 openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v210/WorkflowSinkSecretsMigration.java:88-97 📄 openmetadata-service/src/main/java/org/openmetadata/service/migration/mysql/v210/Migration.java:82 📄 openmetadata-service/src/main/java/org/openmetadata/service/migration/postgres/v210/Migration.java:80
redeployActive catches redeploy failures for each definition, but it calls initializeWorkflowHandler.run() (WorkflowHandler.initialize(config, true)) with no guard. If initialization throws, runDataMigration for v2.1.0 fails and the upgrade stops, even though the secrets are already encrypted in the DB. Other migrations that redeploy workflows (v171, v1122) wrap this call in try/catch so a workflow-engine problem doesn't block the upgrade. Wrap the initialize-and-redeploy step the same way and log the error: the ciphertext is already stored, and the next server start redeploys the definitions.

✅ Edge Case: An emptied batch falls back to the first entity of the original batch

📄 openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/nodes/automatedTask/impl/BatchEntities.java:56-65 📄 openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/nodes/automatedTask/impl/BatchEntities.java:103-105 📄 openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/nodes/automatedTask/impl/BatchEntities.java:124-133
BatchEntities.read returns Optional.empty() when global_entityList is an empty list. The node then takes its per-entity path and reads global_relatedEntity, which still names the first entity of the batch the trigger fetched. A condition can leave the list empty while still taking its continuing edge: this happens when the continuing edge has no condition (continuingOutcome == null, so continuing = evaluated) and the check throws for every entity, for example because the entities were deleted after the fetch. writeIfChanged then stores [] and the result is true. Every later action node acts on relatedEntity, an entity that just failed evaluation. SinkTaskDelegate also skips batch mode for an empty list (it checks !entityList.isEmpty()) and writes that entity to the sink. To fix this, return the list from read whenever it is a List, even an empty one, and let batch nodes and the sink treat an empty batch as nothing to do. Alternatively, have evaluate take the non-continuing outcome when continuing is empty.

✅ Edge Case: Stop request can land on an instance whose process already ended EXCEPTION

📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/WorkflowInstanceRepository.java:62-76 📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/WorkflowInstanceRepository.java:137-139 📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/WorkflowInstanceRepository.java:169-175 📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/WorkflowDocStoreDAOs.java:701 📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/WorkflowDocStoreDAOs.java:710 📄 openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/WorkflowInstanceTerminator.java:154-163
requestStop now also matches EXCEPTION. But finalEndState (L137-139) also records EXCEPTION as a terminal end status when global_exception is set. Here is the race: the end listener writes EXCEPTION, its Flowable transaction has not committed yet, and an admin calls terminate in that window. The root process is still visible and its job is still locked, so the delete is skipped. requestStop matches EXCEPTION, and the endpoint returns 202 with a stop request recorded. The end write's re-read has already run, though, so nothing ever applies the stop. The instance stays EXCEPTION and is never recorded as FAILURE. Before this change the RUNNING-only filter returned 409 in this case. The updated Javadoc also says only FINISHED, FAILURE and SUPERSEDED ends block a later request, which confirms that an EXCEPTION end does not. To fix it, tell a mid-retry EXCEPTION apart from a terminal one, for example by only accepting EXCEPTION while endedAt is null (AND (status = :runningStatus OR (status = :exceptionStatus AND endedAt IS NULL))), or make the end write's re-read also cover an EXCEPTION end.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend safe to test Add this label to run secure Github workflows on PRs skip-pr-checks Bypass PR metadata validation check

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants