Repository navigation
Fixes 36148: Keep approval tasks of long-named workflows bound to their own workflow run - #37856
Conversation
…ir own workflow run Flowable 7.2 replaces a process-definition ID with a bare generated id when "key:version:id" exceeds 64 characters. WorkflowHandler's shared getProcessDefinitionKeyFromId split the ID on ':', so a workflow named like ownerAssignedTagApproval_<UUID> read as key "6308". Its trigger was then treated as non-OpenMetadata, the run got no business key or WorkflowInstance row, and CreateTask produced a task with no instance or definition UUID that TaskRepository adopted into RequestApprovalTaskWorkflow. The helper now reads the key from the deployed definition through RepositoryService, which is served from Flowable's deployment cache. It falls back to the ID prefix only when the engine is not running or the definition cannot be read, including a MyBatis database error raised outside a Flowable command, so callers logging from catch blocks never see it throw. The timer-job cleanup in WorkflowHandler.deploy, which never cancelled the entity-specific timers of long-named periodic workflows, now reads the key the same way. FetchEntitiesImpl also uses the helper so nothing else parses a definition ID; it was not observably broken, because each per-type process is also given its entity type. The rule is recorded in a decision record. Tests: a unit test for the helper, including a key that contains ':' and a database error; a running-engine case and a bare-generated-ID timer job in WorkflowHandlerSchemaUpdateTest; an event IT with a long name that checks the task keeps its workflow and instance UUIDs and that approving it finishes the run; a periodic IT with a long name that checks the run is recorded and the task is bound to it; and test_reviewerChangeDoesNotOverwriteOwnerAssignedApprovalTask now selects its task by the workflow's UUID.
✅ PR checks passedThe linked issue has a description and all required Shipping project fields set. Thanks! |
|
Local Java test run: PASSED — details
Tests run locally
Broader coverage not executed by this focused run
Commandsmvn -B package -pl openmetadata-service -am -Dspring-boot.repackage.skip=true -Dtest=FetchEntitiesImplTest,WorkflowHandlerProcessDefinitionKeyTest,WorkflowHandlerSchemaUpdateTest -Dsurefire.failIfNoSpecifiedTests=false
mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Pmysql-elasticsearch -DintegrationTests.lane=global-state -Dit.test=WorkflowDefinitionResourceIT -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false |
|
Want your agent to iterate on Greptile's feedback? Try greploops. |
…final test_longWorkflowNameKeepsItsApprovalTaskAndCompletesItsRun now reads as deploy, start, bind check, approve and await, each a named helper, and reuses approve(). The locals and parameters added for the deployed-definition key lookup are final.
Code Review ✅ Approved 🟡 Medium riskThe shared key resolver changes run identity, approval-task binding, and timer cleanup across workflow consumers; lookup mismatches could disrupt lifecycle handling. Keeps approval tasks of long-named workflows bound to their own workflow run by reading the process definition key from the deployed Flowable definition instead of splitting the definition ID on VerificationRules No rules evaluated Functional validation Not enabledAuto-approval Not enabledFor more verification details, comment OptionsDisplay: compact → Showing compact verification results. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
|
Thank you for the PR, merging it in |
Closing a workflow-managed task sent the task's terminateProcess message, which reaches a terminate end event with terminateAll and deletes the root process instance. In a periodic batch that tore down the whole trigger and marked the shared run CANCELLED. In parallel approval branches it left the sibling's task open with nothing behind it. - The close now deletes, one at a time, each process holding a Flowable task of the closed task, never the root, so a batch's trigger carries on. A run that is not a periodic batch is recorded CANCELLED first; its other open tasks about the same entity are closed after it ends, because parallel branches overwrite the process-wide customTaskId. - The delete cause is whitelisted in WorkflowFailureListener. - The task lookup narrows by the run only when the task store can be read, so an engine-only lookup no longer fails. - Drop the long-workflow-name fix: #37856 fixed #36148 more completely. - Decision records for the close rule and for the retiring engine keeping its job locks.
* Fixes #36148: Fix governance workflow lifecycle bugs - Closing or bulk-cancelling a workflow-managed task now records its run as CANCELLED and terminates the waiting Flowable process, instead of leaving the run RUNNING forever. - The certification node writes with governance-bot as impersonator, so its write no longer re-triggers the entity's workflows. - The Flowable task lookup by customTaskId also matches the run's business key (indexed), instead of scanning ACT_RU_VARIABLE on every resolve, vote and terminate. The old query is the fallback. - Replacing the engine on a workflow-settings save keeps the retiring executor's job locks, so a job still running is not acquired and run a second time. Server shutdown keeps releasing locks. - unlockJobsOnStartup stays unwired, with a comment on why. - RunApp's wait polls every 5s instead of spinning on the database, logs failed reads and honours interrupts. - A process definition id without a key (a long workflow name) resolves its key from the deployed definition, so its tasks keep the right workflow and run. * End only the closed task's processes, not the trigger root Closing a workflow-managed task sent the task's terminateProcess message, which reaches a terminate end event with terminateAll and deletes the root process instance. In a periodic batch that tore down the whole trigger and marked the shared run CANCELLED. In parallel approval branches it left the sibling's task open with nothing behind it. - The close now deletes, one at a time, each process holding a Flowable task of the closed task, never the root, so a batch's trigger carries on. A run that is not a periodic batch is recorded CANCELLED first; its other open tasks about the same entity are closed after it ends, because parallel branches overwrite the process-wide customTaskId. - The delete cause is whitelisted in WorkflowFailureListener. - The task lookup narrows by the run only when the task store can be read, so an engine-only lookup no longer fails. - Drop the long-workflow-name fix: #37856 fixed #36148 more completely. - Decision records for the close rule and for the retiring engine keeping its job locks. * Record a closed task's run as CANCELLED only after its delete succeeds The close recorded the run CANCELLED before deleting its process, so a delete refused by a job executing on another server left a CANCELLED run with a live process. A run that is not a periodic batch belongs to the closed task alone: its whole process tree is now deleted from its root, which runs no end listener, and CANCELLED is recorded only after the delete succeeded. A periodic batch still deletes only the process holding the task and leaves the run's status to its trigger. endTaskProcess is split into named steps. The decision record states the new order.
Describe your changes:
Fixes #36148
A governance workflow with a long name (for example
ownerAssignedTagApproval_<UUID>, 61 characters) lost its run identity, and its approval task ended up bound to the defaultRequestApprovalTaskWorkflow.Flowable 7.2 builds a process-definition ID as
key:version:idonly while it fits in 64 characters. A longer ID becomes a bare generated number such as6308(BpmnDeployer.getIdForNewProcessDefinition;ACT_RE_PROCDEF.ID_isvarchar(64)). The shared helperWorkflowHandler.getProcessDefinitionKeyFromIdsplit the ID on:and read the key as6308. That caused a chain of failures:CreateTasktherefore created a task with neither an instance UUID nor a definition UUID.TaskRepositoryadopted that task intoRequestApprovalTaskWorkflow.The same wrong key also broke change-request routing in
FilterEntityImpl, stage and failure records, and sink labels. Two places split the ID on their own:WorkflowHandler.deploynever cancelled the old entity-specific timer jobs of a long-named periodic workflow, so duplicate scheduled runs survived a redeploy.FetchEntitiesImplread the entity type from the split key. It was not observably broken: each per-type process is also given its own entity type, which the code falls back to.The helper now reads the key from the deployed definition through
RepositoryService.getProcessDefinition(id), which Flowable serves from its deployment cache. When the engine is not running or the definition cannot be read (an unknown ID, or a database error, including the MyBatisPersistenceExceptionthat escapes unwrapped outside a Flowable command), it falls back to the part of the ID before the first:. It returns null for a null ID and never throws, because most callers use it while logging inside acatch. The timer-job cleanup indeployasks the repository service of the engine it is deploying to, andFetchEntitiesImplnow calls the helper for consistency, so nothing else parses a definition ID. The helper's signature is unchanged, so its 35 call sites in 25 files need no edits.This fix is preventive. Tasks that are already misbound and historic instance rows that were never written are not repaired, as the issue states. Workflow names over about 248 characters still fail at deployment on
ACT_RE_PROCDEF.KEY_ varchar(255); that limit is unchanged and out of scope.Left for follow-ups:
WorkflowFailureListener(L154) takeskey.split("-")[0], so for a UUID-suffixed name like the issue's fixtureisStageStatusEnabledis false and no failure stage row is written. That is the same outcome as before this fix, and as today for any short name containing-.The rule is recorded in
docs/decisions/2026-11-16-a-process-definition-key-is-read-from-its-deployed-definition.md.Type of change:
High-level design:
N/A — small change. Alternatives considered:
:. This relies on Flowable's private ID layout and breaks keys that contain:.Tests:
Use cases covered
<name>Trigger-tagdefinition gets a bare generated ID) records its run, and its approval task is bound to that run and workflow.:resolves to the full deployed key, not the part before the first:.Unit tests
WorkflowHandlerProcessDefinitionKeyTest(6 tests: a bare generated ID, a key containing:, an unknown ID, a MyBatis database error, a null ID, and an engine that is not running). It resetsWorkflowHandler's static state before and after each test.WorkflowHandlerSchemaUpdateTest#runningEngineReadsTheKeyOfABareGeneratedIdFromTheDeployedDefinition, which initializesWorkflowHandlerwith a mocked engine and asserts thatgetProcessDefinitionKeyFromId("6308")returns the deployed 68-character key. Reverting the public helper to the:split, or making it ignore the running engine, fails this test (expected: <ownerAssignedTagApproval_…Trigger> but was: <6308>) while the other 25 tests in the two classes stay green.WorkflowHandlerSchemaUpdateTest#deployCancelsEntitySpecificPeriodicTimerJobs. Its deep-stubbedRepositoryServicenow answers the definition lookup the cleanup makes, and it adds a timer job whose definition has a bare generated ID (6310), which the old split never cancelled.org.openmetadata.service.governanceplusWorkflowRedeployEntryPointTest,IngestionPipelineMigrationEntryPointTestandOntologyEntityDAOTest: 1001 tests, 0 failures, 0 errors.WorkflowHandlerandFetchEntitiesImplare covered by unit tests (JaCoCo).WorkflowHandleris a 2,400-line class, so class-level coverage is not meaningful for this change.Backend integration tests
openmetadata-integration-tests/.WorkflowDefinitionResourceIT.test_longWorkflowNameKeepsItsApprovalTaskAndCompletesItsRunandtest_longPeriodicWorkflowNameRecordsItsRunAndBindsItsTask.test_reviewerChangeDoesNotOverwriteOwnerAssignedApprovalTask.main, mysql-elasticsearch, global-state lane): 3 of 3 fail withConditionTimeoutExceptionon the workflow-UUID selector, for exampleCondition with alias 'open approval task of workflow <id> on ...guardTag' didn't complete within 2 minutes. The opaque-ID precondition guards passed in both new tests, so the fixtures do reproduce Long workflow names lose process identity and bind approval tasks to the default lifecycle #36148.Tests run: 3, Failures: 0, Errors: 0inTEST-org.openmetadata.it.tests.WorkflowDefinitionResourceIT.xmlfor each engine).WorkflowHandlerSchemaUpdateTestchange also fails onmain's production code:deleteJob("generated-id-timer")is "Wanted but not invoked".make java_affected_run ARGS="--scope focused --update-pr"(needs this PR) and--scope full.Local Java test run: PASSED
0e077cd05c81(baseorigin/main)--scope full).Ingestion integration tests
Playwright (UI) tests
Visual regression baselines
Manual testing performed
javaponBpmnDeployer), and that a nestedRepositoryServicecall from a listener reuses the running command context (CommandConfigdefaults tocontextReusePossible=true,REQUIREDpropagation).UI screen recording:
Not applicable — backend-only bug fix.
Checklist:
I have read the CONTRIBUTING document.
My PR title is
Fixes <issue-number>: <short explanation>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: I updated the migration scripts or explained why it is not needed.
For a UI feature or feature task: as part of PR creation, I ran the PR build in Docker with sample data and embedded a verified GitHub-hosted recording plus build/health evidence above (or explained why this requirement is not applicable).
I have added tests (unit / integration / Playwright as applicable) and listed them above.
Self-review: I reviewed the final diff against
REVIEW.md(thepr-checklistskill runs it) and fixed every 🔴 finding, or answered it on the line below.Decision check: adds
docs/decisions/2026-11-16-a-process-definition-key-is-read-from-its-deployed-definition.md.I have added a test that covers the exact scenario we are fixing. For complex issues, comment the issue number in the test for future reference.


Confidence Score: 5/5
The latest changes appear safe to merge.Summary
The PR keeps approval tasks for long-named workflows tied to the correct workflow and run.
The latest changes split the approval test into named helpers without changing its checks. Both previous findings are addressed; no new issues were found.
Reviews (7) · Last reviewed commit: "Split the long-workflow-name IT into nam..." · Reviewed by Greptile