Skip to content

fix(engine): restore optional null semantics and strict ID validation - #3819

Merged
kthoms merged 1 commit into
mainfrom
fix/engine-null-regressions
Oct 12, 2026
Merged

kthoms merged 1 commit into
mainfrom
fix/engine-null-regressions

Conversation

@hauptmedia

@hauptmedia hauptmedia commented Oct 9, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

This PR repairs seven runtime/validation regressions introduced during the engine nullability refactoring. The affected changes went beyond annotations: they added unconditional null assertions, replaced meaningful null values with empty collections, or removed invalid IDs before the existing validation could see them.

The failures were reproduced on the unchanged main baseline 79f9f874bcec4f3ff7423ac39270bfea2b66cfb1; they are not caused by the multi-instance input-mapping fix in #3818. Frontend/SDK test infrastructure is handled separately in #3820.

The introducing commits below were checked against their parent diffs, rather than inferred only from the last blame entry. Existing regression assertions are retained.

1. Historic queries lose the “without tenant” filter

Problem: HistoricProcessInstanceQueryImpl.getTenantIds() returns an empty array when its underlying tenantIds is null. That null has semantic meaning: for withoutTenantId(), the MyBatis mapper uses query.tenantIds == null to add SELF.TENANT_ID_ is null. An empty array satisfies neither the mapper's nonempty-array branch nor its null branch, so the intended tenant predicate disappears.

Impact: a query explicitly requesting only historic instances without a tenant can return additional instances. In the existing test, it returns three instead of one. This is a wrong-result regression; this finding does not by itself establish a general authorization bypass.

Introduced by: b201f1d71647 (#3634), which changed return tenantIds to Objects.requireNonNullElse(tenantIds, new String[0]). bb29f2a744d1 (#3666) later rewrote it as a ternary expression but did not introduce the underlying behavioral change.

Fix: preserve the nullable return value and annotate it accordingly.

Existing regression coverage: MultiTenancyHistoricProcessInstanceQueryTest.shouldQueryByWithoutTenantId and shouldQueryAuthenticatedTenants.

2. Event-based gateway parsing rejects ID-less sibling XML elements

Problem: the parser builds an ID lookup from every sibling XML element around an event-based gateway. An unconditional requireNonNull(sibling.attribute("id")) now assumes that every sibling has an ID, although the existing supported fixtures include ID-less elements, including sequence flows.

Impact: deployment fails with a NullPointerException before normal gateway parsing/validation completes. This affects otherwise supported models and also masks the intended diagnostics for invalid models.

Introduced by: bb29f2a744d1 (#3666), replacing the previous nullable-key insertion with an unconditional null assertion.

Fix: add only siblings with an ID to the lookup. Sequence-flow processing and gateway validation remain in place.

Existing regression coverage: EventBasedGatewayTest, InclusiveGatewayTest.testJoinAfterEventBasedGateway, AsyncTaskTest.testAsyncEventGateway, related history/job-definition tests, and LinkEventTest.testCatchLinkEventAfterEventBasedGatewayNotAllowed.

3. Compensation migration cannot remove an intentionally unmapped event scope

Problem: CompensationInstanceHandler requires both the event-scope migration instruction and its target activity to be non-null. However, an event scope being removed during migration can intentionally have no target mapping. The migration representation already supports that absence so the obsolete scope can be removed.

Impact: migrations involving compensation subscriptions and subprocess removal fail early with a NullPointerException instead of executing the supported scope-removal path. Ten existing tests in the two affected compensation migration classes fail.

Introduced by: bb29f2a744d1 (#3666), which wrapped findSingleMigrationInstruction(...) and getTargetActivity(...) in requireNonNull.

Fix: retain the check that the source compensating execution exists, while allowing the optional mapping and target scope to remain null.

Existing regression coverage: MigrationCompensationRemoveSubProcessTest and MigrationCompensationAddRemoveSubProcessTest, covering execution/activity-instance trees, scope variables, listener behavior and output mappings.

4. Delegate-expression signaling incorrectly requires a Process Application

Problem: ServiceTaskDelegateExpressionActivityBehavior.signal() unconditionally requires a target Process Application before checking whether a context switch is needed. Standalone deployments can legitimately have no Process Application; requiresContextSwitch(...) explicitly handles that case.

Impact: signaling a supported delegate-expression activity fails before the delegate is invoked. Existing error/exception handling, authorization and sequential/parallel multi-instance tests fail through this path.

Introduced by: 35f7af608515, “refactor(engine): Annotate nullability for engine behavior classes”.

Fix: require a non-null Process Application only inside the branch that actually performs a context switch.

Existing regression coverage: DelegationAuthorizationTest.testSignallableActivityBehaviorAsDelegateExpression, delegate-signaling cases in BoundaryErrorEventTest and ErrorEventSubProcessTest, and the sequential/parallel delegate-signaling cases in MultiInstanceTest.

5. Process modification changes null-list and null-element semantics

Problem: two separate changes alter modification input handling:

  • AbstractModificationCmd constructs new HashSet<>(builder.getProcessInstanceIds()) without the previous null guard.
  • ModificationBuilderImpl filters null elements out of the varargs input before command validation.

Impact: a nullable explicit ID list can produce an incidental NullPointerException instead of following the existing selection/validation path. A null element inside an ID array disappears, so the intended invalid-ID validation no longer runs and a different error can surface later.

Introduced by: b201f1d71647 (#3634), which removed the collection null guard and added filter(Objects::nonNull).

Fix: restore the guarded collection step, declare the nullable list accurately, and preserve array elements for the existing command validation.

Existing regression coverage: ModificationExecutionSyncTest.createModificationWithNullProcessInstanceIdsList, createModificationUsingProcessInstanceIdsArrayWithNullValue, and their parameterized asynchronous counterparts in ModificationExecutionAsyncTest.

6. External-task retry updates silently accept lists containing null IDs

Problem: UpdateExternalTaskRetriesBuilderImpl filters null entries out of external-task and process-instance ID lists/arrays. This changes an invalid request such as [existingId, null] into a valid request for a smaller set of instances before validation.

Impact: synchronous or asynchronous retry updates can be accepted instead of rejecting the malformed request. The caller receives different behavior from the established API validation contract.

Introduced by: b201f1d71647 (#3634), which added filter(Objects::nonNull) to all four ID-input overloads.

Fix: preserve null elements so the existing external-task validation / process-instance query validation can reject them. Null collection arguments still follow the existing empty-selection handling.

Regression coverage: retain SetExternalTasksRetriesTest.shouldFailForNullExternalTaskIdSync/Async and add six cases for external-task ID arrays and process-instance ID lists/arrays, each tested through set(...) and setAsync(...). The unchanged implementation fails all six added cases; the repaired implementation passes them.

7. Missing external-task topics produce duplicate diagnostics and an unnecessary null failure

Problem: parseTopic(...) already records the missing-topic model error and returns null. Its caller now adds the same diagnostic a second time and then calls requireNonNull(topicNameProvider).

Impact: an invalid BPMN model no longer follows the normal error-collection path cleanly: the diagnostic is duplicated and parsing encounters an avoidable null assertion. The existing test expects one useful model diagnostic.

Introduced by: bb29f2a744d1 (#3666), adding both the repeated addError(...) and the null assertion.

Fix: keep the error already recorded by parseTopic and use a NullValueProvider to let parsing continue collecting errors. The deployment remains invalid; the placeholder does not make an external task without a topic executable.

Existing regression coverage: ExternalTaskParseTest.testParseExternalTaskWithoutTopic.

Regression verification

The 45 initial expanded-suite failures reproduced on the unchanged base, including with the CI-relevant H2 profile. Existing assertions remain unchanged. Six additional sync/async retry cases check that null entries in external-task and process-instance ID arrays/lists reach the existing validation instead of being silently filtered out.

The updated retry class runs 30 cases: unchanged base fails eight (two existing and six added), and the repaired implementation passes all 30. The complete expanded engine selection on the combined change set passes 16,274 cases, with zero failures/errors and 101 existing skips.

Why existing CI was green

The audited main CI artifact contains 2,222 engine cases and matches the local default baseline testcase set exactly. None of the 18 classes containing the expanded failures ran there. Surefire 3.6.0 reapplies the repository's regex containing .class to JUnit class names; enclosing-class handling explains the partial discovery. See the audited main run and Apache's upstream fix.

Expanded verification uses an explicit selector preserving the same intended exclusions and scanned candidates. Six sequential partitions were checked to have exactly the same class union, and the testcase union contains every previous case plus exactly the six new retry cases. This PR does not change Surefire or repository test-discovery configuration.

Verification scope

The three companion change sets were validated together on 79f9f874bcec4f3ff7423ac39270bfea2b66cfb1: 26,919 distinct Java cases, zero failures/errors and 142 existing skips; all 129 reactor modules completed successfully across verified recovery segments. This was not one uninterrupted build, and it is not a claim that each split branch independently passed the expanded full suite.

This branch is based on ce6e96e4139a006bb3ba6a3fce70f80eb3641f5c. The intervening main change only updates the REST documentation dependency lockfile. Every published changed file was checked byte-for-byte against the tested content.

Legacy browser test execution is explicitly deferred for this run: Chromium cannot create its required Unix socket in the test executor. The 32 UI, 7 SDK browser and 13 Commons browser spec inventories are not claimed as passed. No tests are permanently disabled. Optional external-database/runtime-container/E2E matrices were not run.

The cleanup script's isolated imports phase passed. Its code/test phases encountered existing recipe configuration errors, so the complete cleanup pipeline is not claimed as passed. git diff --check passed.

Repair seven independently reproduced baseline regressions in parsing, migration, delegate signaling, queries, modification and external-task retries. Add six strict synchronous and asynchronous retry regression cases; preserve existing assertions.
@github-actions github-actions Bot added lang:java Pull requests that update Java code scope:core-api Changes to the core API: engine, dmn-engine, feel-engine, REST API, OpenAPI scope:tests Changes affecting only test code labels Oct 9, 2026
@hauptmedia
hauptmedia requested a review from kthoms October 9, 2026 14:06
@hauptmedia

Copy link
Copy Markdown
Collaborator Author

@kthoms while investigating another issue one of my agents found these issues, can you have a look if they are valid? Thx

@sonarqubecloud

sonarqubecloud Bot commented Oct 9, 2026

Copy link
Copy Markdown

@kthoms

kthoms commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

I will check this, thanks already!

@hauptmedia hauptmedia added this to the 2.2.0 milestone Oct 12, 2026
@hauptmedia hauptmedia added the bug Something isn't working label Oct 12, 2026

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

  1. Historic queries lose the “without tenant” filter: Analysis & Fix ok
  2. Event-based gateway parsing rejects ID-less sibling XML elements: Analysis & Fix ok (BpmnParse)
  3. Compensation migration cannot remove an intentionally unmapped event scope: Analysis & Fix ok
  4. Delegate-expression signaling incorrectly requires a Process Application: Analysis & Fix ok
  5. Process modification changes null-list and null-element semantics: Analysis & Fix ok
  6. External-task retry updates silently accept lists containing null IDs: Analysis & Fix ok
  7. Missing external-task topics produce duplicate diagnostics and an unnecessary null failure: Analysis & Fix ok

@kthoms
kthoms marked this pull request as ready for review October 12, 2026 14:03
Copilot AI balanced review requested due to automatic review settings October 12, 2026 14:03

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.

@kthoms

kthoms commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

Thank you @hauptmedia and your AI army for the valuable fixes!

@kthoms
kthoms merged commit cc9489c into main Oct 12, 2026
18 checks passed
@kthoms
kthoms deleted the fix/engine-null-regressions branch October 12, 2026 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working lang:java Pull requests that update Java code scope:core-api Changes to the core API: engine, dmn-engine, feel-engine, REST API, OpenAPI scope:tests Changes affecting only test code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants